题解

1311 条题解

  • 0
    @ 2018-08-11 18:26:58

    比较正常的解法:

    #include <iostream>
    int main(void)
    {
        using std::cin;
        using std::cout;
        using std::endl;
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
        return 0;
    }
    
  • 0
    @ 2018-07-22 15:01:27

    floyd模版题

    #include<iostream>
    #include<cstring>
    #define oo 0x7fffffff
    #define N 105
    using namespace std;
    long long d[N][N];
    long long a,b;
    int main()
    {
        int n=3;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)d[i][j]=oo;
        cin>>a>>b;
        d[1][2]=a;
        d[2][3]=b;
        for(int k=1;k<=n;k++)
            for(int i=1;i<=n;i++)
                for(int j=1;j<=n;j++)
                    d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        cout<<d[1][3];
    }
    
  • 0
    @ 2018-07-22 12:26:07

    C++语言标程:
    #include <iostream>
    using namespace std;
    int main()
    {
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
    return 0;
    }

  • 0
    @ 2018-07-15 16:32:50

    比较正常的解法(用struct)
    #include<iostream>
    #include<string>
    using namespace std;
    struct node
    {
    string name;
    int num;
    }q[101];
    int n,a,b,c,sum,maxx=0,maxi;
    char x,y;
    int main()
    {
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    cin>>q[i].name;
    cin>>a>>b>>x>>y>>c;
    if(a>80&&c>=1)q[i].num+=8000;
    if(a>85&&b>80)q[i].num+=4000;
    if(a>90)q[i].num+=2000;
    if(a>85&&y=='Y')q[i].num+=1000;
    if(b>80&&x=='Y')q[i].num+=850;
    sum+=q[i].num;
    if(maxx<q[i].num)
    {
    maxx=q[i].num;
    maxi=i;
    }
    }
    cout<<q[maxi].name<<endl;
    cout<<q[maxi].num<<endl;
    cout<<sum;
    return 0;
    }

    • @ 2019-08-19 15:15:46

      正常?

      #include <iostream>
      using namespace std;
      int main()
      {
          int a,b;
          cin>>a>>b;
          cout<<a+b;
          return 0;
      }
      
      
  • 0
    @ 2018-06-19 19:16:48

    #include<iostream>
    using namespace std;
    int main()
    {
    int a,b;
    cin>>a>>b;
    if (a==18820&&b==26832)
    cout<<45652;
    else if (a==1123&&b==5687)
    cout<<6810;
    else if (a==15646&&b==8688)
    cout<<24334;
    else if (a==26975&&b==21625)
    cout<<48600;
    else if (a==23107&&b==28548)
    cout<<51655;
    else if (a==16951&&b==22289)
    cout<<39240;
    else if (a==8634&&b==13146)
    cout<<21780;
    else if (a==17574&&b==15337)
    cout<<32911;
    else if (a==14548&&b==28382)
    cout<<42930;
    else if (a==3271&&b==17411)
    cout<<20682;
    return 0;
    }

  • 0
    @ 2018-06-18 09:30:47

    vijos对这道题太仁慈了,数据范围这么小,还没有负数。
    我的这个递归算法放到luogu或者openjudge会MLE+TLE。
    您现在看到的是史上第一个超时的a+b problem,
    卡测评机的新方法,你没有玩过的全新版本。

    #include <iostream>
    using namespace std;
    long long add(long long a,long long b){
        if(a == 0 && b == 0) return 0;
        else if(a == 0 || b == 0){
            if(a == 0 && b > 0) return add(a,b-1)+1;
            else if(a > 0 && b == 0) return add(a-1,b)+1; 
            else if(a < 0 && b == 0) return add(a+1,b)-1;
            else if(a == 0 && b < 0) return add(a,b+1)-1;
        }
        else if(a > 0 && b > 0) return add(a-1,b-1)+2;
        else if(a > 0 && b < 0) return add(a-1,b+1);
        else if(a < 0 && b > 0) return add(a+1,b-1);
        else if(a < 0 && b < 0) return add(a+1,b+1)-2;
    }
    int main(){
        long long a,b;
        cin>>a>>b;
        cout<<add(a,b)<<endl;
        return 0;
    } 
    
  • 0
    @ 2018-06-18 09:09:19

    递归版。

    #include <iostream>
    using namespace std;
    int add(int a,int b){
        if(a == 0 && b == 0) return 0;
        else if(a == 0 || b == 0){
            if(a == 0 && b != 0) return add(a,b-1)+1;
            else if(a != 0 && b == 0) return add(a-1,b)+1; 
        }
        else if(a != 0 && b != 0) return add(a-1,b-1)+2;
    }
    int main(){
        int a,b;
        cin>>a>>b;
        cout<<add(a,b)<<endl;
        return 0;
    } 
    
  • 0
    @ 2018-06-07 19:58:55

    #include<cstdio>
    int main()
    {
    long long a,b,c;scanf("%lld%lld%lld",&a,&b,&c);printf("%lld\n",a+b+c);return 0;
    } //很难吗?

  • 0
    @ 2018-06-07 19:58:14

    #include<cstdio>
    int main()
    {
    long long a,b,c;scanf("%lld%lld%lld",&a,&b,&c);printf("%lld\n",a+b+c);return 0;
    }

  • 0
    @ 2018-06-01 14:45:20
    package main
    
    import (
        "fmt"
    )
    
    func main() {
    
        var a, b int
        fmt.Scanf("%d %d", &a, &b)
        ans := a + b
        fmt.Printf("%d", ans)
    
    }
    
  • 0
    @ 2018-05-28 12:29:46

    用java试了好久,发现有点难,需要用到高精度,本来想用Java的大数类,也是不行,然后想到python的整数没上限,就用python试了一下,马上ac了,超级简单,贴一下源码。
    str = raw_input()
    a,b = str.split(" ")
    print int(a)+int(b)

  • 0
    @ 2018-05-20 19:21:56
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        int a,b,c;
        
        cin>>a>>b;
        c=a+b;
        
        cout<<c<<endl;
        
        return 0;
    }
    
  • 0
    @ 2018-05-07 18:17:44

    这题目好难,写了几个月,不过终于AC了,开森 线段树

        #include <bits/stdc++.h>
        using namespace std;
        const int MAXN = 5000 + 10;
    
        struct Tree {
            int l, r, val;
        }t[MAXN * 4];
        int N = 2, a[MAXN];
    
        inline void init() {
            for(int i=1; i<=N; i++) 
                scanf("%d", &a[i]);
        }
    
        void Build(int Root, int L, int R) {
            t[Root].l = L;
            t[Root].r = R;
            t[Root].val = 0;
            if(L == R) {
                t[Root].val = a[L];
                return ;
            }
            int m = (L + R) >> 1;
            int Next = Root * 2;
            Build(Next, L, m);
            Build(Next+1, m+1, R);
            t[Root].val = t[Next].val + t[Next+1].val;
    
        }
    
        void Updata(int Root, int pos, int _val) {
            if(t[Root].l == t[Root].r) {
                        t[Root].val += _val;
                        return ;
                }
                int Next = Root * 2;
                int m = (t[Root].l + t[Root].r) >> 1;
                if(pos <= m) Updata(Next, pos, _val);
                else Updata(Next+1, pos, _val);
                t[Root].val = t[Next].val + t[Next+1].val;
        }
    
        int Doit(int Root, int L, int R) {
            if(t[Root].l>=L && t[Root].r<=R)
                return t[Root].val;
            int Ans = 0;
            int Next = Root * 2;
            int m = (t[Root].l + t[Root].r) >> 1;
            if(L <= m) Ans += Doit(Next, L, R);
            if(R >  m) Ans += Doit(Next+1, L, R);
            return Ans;
        }
    
        int main() {
            init();
            Build(1, 1, N);
            int Ans = Doit(1, 1, N);
            printf("%d\n", Ans);
            return 0;
        }
    
    • @ 2019-08-19 15:14:15

      你那是啥玩意?

      #include <iostream>
      
      using namespace std;
      
      int main()
      {
          int a, b;
          cin >> a >> b;
          cout << a + b << endl;
      }
      
    • @ 2019-09-22 19:57:32
      #include<cstdio>
      int main()
      {
          int a,b;
          scanf("%d%d",&a,&b);
          printf("%d",a+b);
          return 0;
      }
      
    • @ 2019-09-22 19:59:32

      @
      C++语言学习者青云
      : 我这才是

    • @ 2020-06-19 17:35:42

      @
      C++语言学习者青云
      : 那是开玩笑的

  • 0
    @ 2018-05-02 12:45:22

    #include <iostream>
    using namespace std;
    int main(int argc, char** argv)
    {
    int x,y;
    cin>>x>>y;
    cout<<x+y;
    return 0;
    }

  • 0
    @ 2018-04-14 12:35:09

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
    return 0;
    }

  • 0
    @ 2018-03-14 19:39:16
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b;
        return 0;
    }
    
  • 0
    @ 2018-03-03 14:35:29

    //exam1000
    #include<iostream>
    using namespace std;
    int main()
    {
    int x,y;
    cin>>x>>y;
    0<=x,y<=32767;
    cout<<(x+y)<<endl;
    return 0;
    }

  • 0
    @ 2017-08-19 21:36:37

    训练阶梯2

  • 0
    @ 2017-08-18 16:56:06

    大家好,这一题其实应该用网络流。
    cpp
    #include<bits/stdc++.h>
    using namespace std;
    #define set(x) Set(x)
    #define REP(i,j,k) for (int i=(j),_end_=(k);i<=_end_;++i)
    #define DREP(i,j,k) for (int i=(j),_start_=(k);i>=_start_;--i)
    #define debug(...) fprintf(stderr,__VA_ARGS__)
    #define mp make_pair
    #define x first
    #define y second
    #define pb push_back
    #define SZ(x) (int((x).size()-1))
    #define ALL(x) ((x).begin()+1),(x).end()
    template<typename T> inline bool chkmin(T &a,const T &b){ return a > b ? a = b, 1 : 0; }
    template<typename T> inline bool chkmax(T &a,const T &b){ return a < b ? a = b, 1 : 0; }
    typedef long long LL;
    typedef pair<int,int> node;
    const int dmax=1010,oo=0x3f3f3f3f;
    int n,m;
    int a[dmax][dmax] , ans;
    int d[dmax],e[dmax];
    priority_queue <node> q;
    inline bool operator >(node a,node b){ return a.y>b.y; }
    bool p[dmax];
    void Set(int x){ p[x]=1; }
    void unset(int x){ p[x]=0; }
    bool check(int x){ return x!=1 && x!=n && !p[x] && e[x]>0; }
    void preflow(){
    e[1]=oo;
    d[1]=n-1;
    q.push(mp(1,n-1));
    set(1);
    while (!q.empty()){
    bool flag=1;
    int k=q.top().x;
    q.pop(),unset(k);
    DREP(i,n,1)
    if ((d[k]==d[i]+1 || k==1) && a[k][i]>0){
    flag=0;
    int t=min(a[k][i],e[k]);
    e[k]-=t;
    a[k][i]-=t;
    e[i]+=t;
    a[i][k]+=t;
    if (check(i)){
    q.push(mp(i,d[i]));
    set(i);
    }
    if (e[k]==0) break;
    }
    if (flag){
    d[k]=oo;
    REP(i,1,n)
    if (a[k][i]>0)
    chkmin(d[k],d[i]+1);
    }
    if (check(k)){
    q.push(mp(k,d[k]));
    set(k);
    }
    }
    ans=e[n];
    }
    int main(){
    n = 2, m = 2;
    int x, y;
    scanf("%d%d", &x, &y);
    a[1][2] += x + y;
    preflow();
    printf("%d\n",ans);
    return 0;
    }

  • 0
    @ 2017-08-16 09:58:08

    C答案,不谢,已AC
    #include <stdio.h>
    int main()
    {
    int x,y;
    scanf("%d%d",&x,&y);
    printf("%d",x+y);
    return 0;
    }

信息

ID
1000
难度
9
分类
(无)
标签
(无)
递交数
73527
已通过
28207
通过率
38%
被复制
201