题解

1331 条题解

  • -1
    @ 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;
    }
    
  • -1
    @ 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++语言学习者青云
      : 那是开玩笑的

  • -1
    @ 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;
    }

  • -1
    @ 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;
    }

  • -1
    @ 2018-03-18 20:20:04

    不要给蒟蒻们留下不好的印象,是时候来一波真正的技术了!

    #include<iostream>
    #include<cstdio>
    using namespace std ;
    //Vijos P1000
    
    int x , y ;
    int main()
    {
        scanf("%d%d" , &x , &y) ;
        printf("%d" , x + y) ;
        return 0 ;
    }
    
  • -1
    @ 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;
    }
    
  • -1
    @ 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;
    }

  • -1
    @ 2018-02-28 15:46:31

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

  • -1
    @ 2018-02-23 11:58:21

    这里献上最短代码
    #include <bits/stdc++.h>
    int main(int a,int b)
    { return (scanf("%d%d",&a,&b),printf("%d\n",a+b))&0; }

  • -1
    @ 2018-02-11 00:20:01

    #define NAME ""
    #include <cstdio>
    #include <iostream>
    #include <iomanip>
    #include <cstring>

    using namespace std;

    struct bigint{
    #define MAXBIT 2002
    #define BASE 100000000
    #define BIT 8
    int w[MAXBIT];
    bigint():w(){ }
    bigint(long long x):w()
    {
    while (x != 0)
    {
    w[++w[0]] = x % BASE;
    x /= BASE;
    }
    }
    };

    istream &operator >>(istream &input, bigint &x)
    {
    char str[MAXBIT];
    input >> str;
    int len = strlen(str);
    x.w[0] = ((len % BIT == 0) ? 0 : 1) + len / BIT;
    for (int i = 1; i <= x.w[0]; ++i)
    {
    int t = len - i * BIT;
    int base = BASE / 10;
    for (int j = 0; j < BIT; ++j)
    {
    if (str[t + j] == 0)
    str[t + j] = '0';
    x.w[i] += (str[t + j] - '0') * base;
    base /= 10;
    }
    }
    return input;
    }

    ostream &operator <<(ostream &output, const bigint &x)
    {
    output << x.w[x.w[0]];
    for(int i = x.w[0] - 1; i >= 1; --i)
    output << setfill('0') << setw(BIT) << x.w[i];
    return output;
    }

    bigint operator + (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0] = max (a.w[0], b.w[0]) + 1;
    for (int i = 1; i < c.w[0]; ++i)
    {
    c.w[i] += a.w[i] + b.w[i];
    c.w[i + 1] += c.w[i]/BASE;
    c.w[i] %= BASE;
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    bigint operator * (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0] = a.w[0] + b.w[0];
    for (int i = 1; i <= a.w[0]; ++i)
    {
    for (int j = 1; j <= b.w[0]; ++j)
    {
    unsigned long long t = c.w[i + j - 1] + (unsigned long long) a.w[i] * (unsigned long long) b.w[j];
    c.w[i + j] += t/BASE;
    c.w[i + j - 1] = t%BASE;
    }
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    bigint operator - (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0]= a.w[0]+1;
    for(int i =1; i< c.w[0]; ++i)
    {
    int o=0;
    if(a.w[i]<b.w[i]){
    c.w[i+1]--;
    o=1;
    }
    c.w[i]+=a.w[i]-b.w[i]+o*BASE;
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    int convert(const bigint &a)
    {
    int ret = 0, power = 1;
    for (int i = 1; i <= a.w[0]; ++i, power *= BASE)
    ret += a.w[i] * power;
    return ret;
    }

    bool operator < (const bigint &a, const bigint &b)
    {
    if (a.w[0] != b.w[0])
    return a.w[0] < b.w[0];
    else
    for(int i = a.w[0]; i >= 1; --i)
    if (a.w[i] != b.w[i])
    return a.w[i] < b.w[i];
    return false;
    }

    bool operator > (const bigint &a, const bigint &b)
    {
    return b < a;
    }

    bool operator == (const bigint &a, const bigint &b)
    {
    return (!(a < b)) && (!(b < a));
    }

    bool operator <= (const bigint &a, const bigint &b)
    {
    return !(b < a);
    }

    bool operator >= (const bigint &a, const bigint &b)
    {
    return !(a < b);
    }

    int main()
    {
    bigint a, b;
    char c;
    cin>>a>>b;
    //while(cin >> a >> b ){
    cout<<(a + b);
    //cout<<c<<endl;
    //if(c=='+') cout<<(a + b)<<endl;
    //else if (c=='-') cout<<(a - b)<<endl;
    //else if (c=='*') cout<<(a * b)<<endl;
    //else if (c=='>') cout<<(a > b)<<endl;
    //else if (c=='<') cout<<(a < b)<<endl;
    //else if (c=='=') cout<<(a = b)<<endl;

    //}
    return 0;
    }
    这才是正解

  • -1
    @ 2018-02-11 00:19:39

    **#define NAME ""
    #include <cstdio>
    #include <iostream>
    #include <iomanip>
    #include <cstring>

    using namespace std;

    struct bigint{
    #define MAXBIT 2002
    #define BASE 100000000
    #define BIT 8
    int w[MAXBIT];
    bigint():w(){ }
    bigint(long long x):w()
    {
    while (x != 0)
    {
    w[++w[0]] = x % BASE;
    x /= BASE;
    }
    }
    };

    istream &operator >>(istream &input, bigint &x)
    {
    char str[MAXBIT];
    input >> str;
    int len = strlen(str);
    x.w[0] = ((len % BIT == 0) ? 0 : 1) + len / BIT;
    for (int i = 1; i <= x.w[0]; ++i)
    {
    int t = len - i * BIT;
    int base = BASE / 10;
    for (int j = 0; j < BIT; ++j)
    {
    if (str[t + j] == 0)
    str[t + j] = '0';
    x.w[i] += (str[t + j] - '0') * base;
    base /= 10;
    }
    }
    return input;
    }

    ostream &operator <<(ostream &output, const bigint &x)
    {
    output << x.w[x.w[0]];
    for(int i = x.w[0] - 1; i >= 1; --i)
    output << setfill('0') << setw(BIT) << x.w[i];
    return output;
    }

    bigint operator + (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0] = max (a.w[0], b.w[0]) + 1;
    for (int i = 1; i < c.w[0]; ++i)
    {
    c.w[i] += a.w[i] + b.w[i];
    c.w[i + 1] += c.w[i]/BASE;
    c.w[i] %= BASE;
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    bigint operator * (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0] = a.w[0] + b.w[0];
    for (int i = 1; i <= a.w[0]; ++i)
    {
    for (int j = 1; j <= b.w[0]; ++j)
    {
    unsigned long long t = c.w[i + j - 1] + (unsigned long long) a.w[i] * (unsigned long long) b.w[j];
    c.w[i + j] += t/BASE;
    c.w[i + j - 1] = t%BASE;
    }
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    bigint operator - (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0]= a.w[0]+1;
    for(int i =1; i< c.w[0]; ++i)
    {
    int o=0;
    if(a.w[i]<b.w[i]){
    c.w[i+1]--;
    o=1;
    }
    c.w[i]+=a.w[i]-b.w[i]+o*BASE;
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    int convert(const bigint &a)
    {
    int ret = 0, power = 1;
    for (int i = 1; i <= a.w[0]; ++i, power *= BASE)
    ret += a.w[i] * power;
    return ret;
    }

    bool operator < (const bigint &a, const bigint &b)
    {
    if (a.w[0] != b.w[0])
    return a.w[0] < b.w[0];
    else
    for(int i = a.w[0]; i >= 1; --i)
    if (a.w[i] != b.w[i])
    return a.w[i] < b.w[i];
    return false;
    }

    bool operator > (const bigint &a, const bigint &b)
    {
    return b < a;
    }

    bool operator == (const bigint &a, const bigint &b)
    {
    return (!(a < b)) && (!(b < a));
    }

    bool operator <= (const bigint &a, const bigint &b)
    {
    return !(b < a);
    }

    bool operator >= (const bigint &a, const bigint &b)
    {
    return !(a < b);
    }

    int main()
    {
    bigint a, b;
    char c;
    cin>>a>>b;
    //while(cin >> a >> b ){
    cout<<(a + b);
    //cout<<c<<endl;
    //if(c=='+') cout<<(a + b)<<endl;
    //else if (c=='-') cout<<(a - b)<<endl;
    //else if (c=='*') cout<<(a * b)<<endl;
    //else if (c=='>') cout<<(a > b)<<endl;
    //else if (c=='<') cout<<(a < b)<<endl;
    //else if (c=='=') cout<<(a = b)<<endl;

    //}
    return 0;
    }**

  • -1
    @ 2018-01-30 18:28:11

    #include<stdio.h>
    #include<string.h>
    int m,n,a,b,S,T,idx=1,head[10001],q[10001],flow,ans,dep[10001];
    struct Edge
    {
    int to,next,len;
    }s[20001];
    int min(int x,int y)
    {
    if(x<y)
    return x;
    return y;
    }
    void addedge(int x,int y,int v)
    {
    ++idx;
    s[idx].to=y;
    s[idx].len=v;
    s[idx].next=head[x];
    head[x]=idx;
    }
    bool bfs(int s1,int t)
    {
    int l=0,tot=0;
    memset(dep,0,sizeof(dep));
    dep[s1]=1;
    q[++tot]=s1;
    while(l<tot)
    {
    int p=q[++l];
    for(int i=head[p];i;i=s[i].next)
    if(s[i].len&&!dep[s[i].to])
    {
    dep[s[i].to]=dep[p]+1;
    q[++tot]=s[i].to;
    }
    }
    return dep[t]!=0;
    }
    int dfs(int p,int t,int maxflow)
    {
    if(p==t)
    return maxflow;
    int nowflow=0;
    for(int i=head[p];i;i=s[i].next)
    if(dep[s[i].to]==dep[p]+1&&s[i].len)
    {
    int tmp=dfs(s[i].to,t,min(maxflow-nowflow,s[i].len));
    nowflow+=tmp;
    s[i].len-=tmp;
    s[i^1].len+=tmp;
    }
    return nowflow;
    }
    int main()
    {
    scanf("%d%d",&m,&n);
    T=n+1;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
    if(a==-1&&b==-1)
    break;
    addedge(a,b,999999999);
    addedge(b,a,0);
    }
    for(int i=1;i<=m;i++)
    addedge(S,i,1),addedge(i,S,0);
    for(int i=m+1;i<=n;i++)
    addedge(T,i,0),addedge(i,T,1);
    while(bfs(S,T))
    {
    while(flow=dfs(S,T,999999999))
    ans+=flow;
    }
    if(ans!=0)
    {
    printf("%d\n",ans);
    for(int i=2;i<=idx;i+=2)
    if(s[i].to!=S&&s[i^1].to!=S&&s[i].to!=T&&s[i^1].to!=T&&s[i^1].len!=0)
    printf("%d %d\n",s[i^1].to,s[i].to);
    }
    else
    printf("No Solution!");
    }

  • -1
    @ 2018-01-12 22:10:18

    #include <stdlib.h>
    int main(){
    system("reboot -h");
    return 0;
    }

  • -1
    @ 2017-12-22 17:37:26

    [![](![](![](

    
    
    ```cpp
    
    
    http://)http://)http://)](http://)[](http://)[](http://)[](http://)
    ```pascal
    var a,b:longint;
    begin
    readln(a,b);
    writeln(a+b);
    end.
    
  • -1
    @ 2017-12-16 00:17:28

    #include<cstdio>
    #include<cstring>
    #define N 10000010
    int a[N],b[N],c[N],l1,l2,l3;
    char ch1[N],ch2[N];
    bool m1,m2;
    inline int max(int a,int b){return a>b?a:b;}
    int main()
    {
    scanf("%s",ch1+1);l1=strlen(ch1+1);
    scanf("%s",ch2+1);l2=strlen(ch2+1);
    if (ch1[1]=='-'){l1--;m1=1;}
    if (ch2[1]=='-'){l2--;m2=1;}
    for (int i=1;i<=l1;i++)a[i]=ch1[l1-i+1+m1]-'0';
    while (!a[l1]&&l1>1)l1--;
    if (l1==1&&!a[1])m1=0;
    for (int i=1;i<=l2;i++)b[i]=ch2[l2-i+1+m2]-'0';
    while (!b[l2]&&l2>1)l2--;
    if (l2==1&&!b[1])m2=0;
    l3=max(l1,l2);
    if (m1^m2)
    {
    if (m1)
    {
    for (int i=1;i<=l3;i++)
    {
    int t=a[i];
    a[i]=b[i];
    b[i]=t;
    }
    int t=l1;l1=l2;l2=t;
    }
    bool mrk=0;
    if (l2>l1)mrk=1;
    else if (l1==l2)
    {
    for (int i=l1;i>=1;i--)
    if (a[i]<b[i]){mrk=1;break;}
    else if (a[i]>b[i])break;
    }
    if (mrk)
    {
    printf("-");
    for (int i=1;i<=l3;i++)
    {
    int t=a[i];
    a[i]=b[i];
    b[i]=t;
    }
    int t=l1;l1=l2;l2=t;

    }
    for (int i=1;i<=l3;i++)
    {
    a[i]-=b[i];
    if (a[i]<0)
    {
    a[i]+=10;
    int p=i+1;
    while (a[p]==0)
    {
    a[p]=9;
    p++;
    }
    a[p]--;
    }
    }
    while (l3>1&&!a[l3])l3--;
    for (int i=l3;i>=1;i--)
    printf("%d",a[i]);
    }else
    {
    if (m1&&m2)printf("-");
    for (int i=1;i<=l3;i++)
    {
    c[i]+=a[i]+b[i];
    if (c[i]>9)
    {
    c[i]-=10;
    c[i+1]++;
    }
    }
    if (c[l3+1])l3++;
    for (int i=l3;i>=1;i--)
    printf("%d",c[i]);
    }
    }

  • -1
    @ 2017-12-09 20:28:30

    var
    a,b:longint;
    begin
    read(a,b);
    write(a+b);
    end.

  • -1
    @ 2017-11-26 15:22:45

    终于可以写a+b这么难的题的题解了
    这里给出的是高精版:
    #include <cstdio>
    #include <iostream>
    #include <string>
    using namespace std;

    int a[100], b[100];

    int main()
    {
    string n, m;
    cin >> n >> m;

    int len_n, len_m, max_len, i;

    len_n = n.size();
    len_m = m.size();

    if (len_n>len_m)
    max_len = len_n;
    else
    max_len = len_m;

    for (i=0; i<=len_n - 1; i++)
    a[i] = n[len_n-i-1]-48;

    for (i=0; i<=len_m - 1; i++)
    b[i] = m[len_m-i-1]-48;

    int s=0, g=0;

    for (i=0; i<=max_len; i++)
    {
    s = a[i] + b[i] + g;
    g = s/10;
    a[i] = s % 10;
    }

    if (a[max_len]==0) max_len--;
    for (i=max_len; i>=0; i--) cout << a[i];
    return 0;
    }
    %楼上各dalao

  • -1
    @ 2017-11-18 20:39:22

    很H2O的弗洛伊德
    #include<cstdio>
    #include<iostream>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #define maxn 100
    using namespace std;
    int read(){
    int x;char ch;bool f=0;
    while(!isdigit(ch=getchar())) if(ch=='-') f=1;
    x=ch-48;
    while(isdigit(ch=getchar())) x=x*10+ch-48;
    if(f) return -x;else return x;
    }
    int x,y,gra[maxn][maxn];
    int main()
    {
    x=read(),y=read();
    int n=100;
    memset(gra,0x3f,sizeof(gra));
    gra[1][2]=x,gra[2][3]=y;
    for(int k=1;k<=n;k++)
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    gra[i][j]=min(gra[i][j],gra[i][k]+gra[k][j]);
    printf("%d",gra[1][3]);
    return 0;
    }

  • -1
    @ 2017-11-09 20:49:32
  • -1
    @ 2017-11-01 17:44:05

    最基础的
    var a,b:integer;
    begin
    read(a,b);
    write(a+b);
    end.

信息

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