题解

1337 条题解

  • -1
    @ 2017-08-16 18:26:54

    C++,我用个二进制吧。。。
    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    int main()
    {
    int a,b,s=0,s1=0,i=0,na=0,nb=0;
    cin>>a>>b;
    if(a<=0) na=1,a*=-1;
    while(a!=0)
    {
    if(a%2!=0)
    s+=pow(2,a%2*i);
    a/=2;
    i++;
    }
    i=0;
    if(na==1) s*=-1;
    if(b<=0) nb=1,b*=-1;
    while(b!=0)
    {
    if(b%2!=0)
    s1+=pow(2,b%2*i);
    b/=2;
    i++;
    }
    if(nb==1) s1*=-1;
    cout<<s+s1;;
    return 0;
    }

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

  • -1
    @ 2017-08-10 22:03:50

    var a,b:longint;
    begin
    readln(a,b);
    writeln(a+b);
    end.

  • -1
    @ 2017-08-10 22:03:10

    var n,k,i,num,sum,ans:longint; a:array[0..20] of longint;

    function pangduan(n:longint):integer;
    var xx,i:integer;
    begin
    xx:=trunc(sqrt(n+1));
    for i:=2 to xx do
    if (n mod i=0) then exit(0);
    exit(1);
    end;

    procedure doit(t:longint);
    var p,i:longint;
    begin
    if (num=k) then
    begin
    p:=pangduan(sum);
    if (p=1) then inc(ans);
    exit;
    end;
    for i:=t+1 to n do
    begin
    inc(num);
    sum:=sum+a[i];
    doit(i);
    sum:=sum-a[i];
    dec(num);
    end;
    end;

    begin
    readln(n,k);
    for i:=1 to n do read(a[i]);
    for i:=1 to n-k+1 do
    begin
    num:=1;
    sum:=a[i];
    doit(i);
    end;
    writeln(ans);
    end.

  • -1
    @ 2017-08-10 19:11:40

    冷清啊。。我来一发Python3的题解

    a, b = map(int, input().split())
    print(a + b)
    

    恩 就是这么简洁qwq

  • -1
    @ 2017-08-05 11:40:48
    #include <iostream>
    using namespace std;
    int main()
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b;
        return 0;
    }
    
  • -1
    @ 2017-08-05 11:40:27

    #include <iostream>
    using namespace std;
    int main()
    {
    int a,b;
    cin>>a>>b;
    cout<<a+b;
    return 0;
    }

  • -1
    @ 2017-08-03 18:41:04

    #include<cstdio>
    //调用头文件。
    using namespace std;
    int main()
    {
    int a,b;//定义a,b。
    scanf("%d%d",&a,&b);//通过scanf格式化输入。
    printf("%d",a+b);//直接输出表达式即可
    return 0;
    }

  • -1
    @ 2017-07-13 15:52:01

    #include<iostream>
    using namespace std;
    int main()
    {
    int a,b,c;
    cin>>a>>b;
    c=a+b;
    cout<<c<<endl;
    return 0;
    }

  • -1
    @ 2017-07-12 15:01:01

    很简单

    #include <cstdio>
    #include <iostream>
    using namespace std;
    int main() {
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
        return 0;
    }
    
  • -1
    @ 2017-07-09 11:46:18

    #include<iostream>
    #include<cstdio>
    #include<ctime>
    #include<algorithm>
    #include<cstdlib>
    #include<cmath>
    #include<cstring>
    using namespace std;
    int main()
    {
    int A,B;
    cin>>A>>B;
    cout<<A+B;
    return 0;
    }

  • -1
    @ 2017-03-05 12:02:25

    main函数自递归和位运算

    #include<bits/stdc++.h>
    int main(int a,int b,int k)
    {
        if (k) scanf("%d%d",&a,&b);
        printf("%d",b==0?a:main(a^b,(a&b)<<1,0));
        exit(0);
    }
    
  • -1
    @ 2017-01-31 10:32:00

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

  • -1
    @ 2017-01-25 11:23:57

    走一波面向对象的A+B。
    <pre>
    #include <bits/stdc++.h>

    using namespace std;

    class Something
    {
    friend istream & operator>>(istream & is, Something & as);
    friend ostream & operator<<(ostream & os, Something & as);
    public:
    int a, b;
    int sum(int x, int y);
    Something & operator+(int z);
    Something & operator+(Something b);

    };

    istream & operator>>(istream & is, Something & as)
    {
    is >> as.a;
    return is;
    }

    ostream & operator<<(ostream & os, Something & as)
    {
    os << as.a;
    return os;
    }

    int Something::sum(int x, int y)
    {
    return x + y;
    }

    Something & Something::operator+(int z)
    {
    a += z;
    return *this;
    }

    Something & Something::operator+(Something b)
    {
    a += b.a;
    return *this;
    }

    int main(int argc, char const *argv[])
    {
    Something sd, st;
    cin >> sd >> st;
    cout << sd + st;
    return 0;
    }
    </pre>

  • -1
    @ 2017-01-22 14:12:30

    #include<iostream> //基础头文件
    using namespace std; //自定义函数
    int main() //输入命令
    {
    int a,b=0,n=2; //1.定义a,用来输入两个数。 2.定义b,用来计数输入的两个数。 3.定义n,用来循环2次。
    for(int i=1;i<=n;i++) //开始循环,循环次数n,n=2
    {
    cin>>a; //输入a;经循环共两次
    b+=a; //计数,为了方便统计,输出时直接把b输出。
    } //循环结束。
    cout<<b; //输出循环后的结果。
    return 0;
    }

  • -1
    @ 2017-01-18 17:51:33
    #include <stdio.h>
    int main()
    {
        int a, b;
        scanf("%d%d", &a, &b);
        printf("%d\n", a + b);
        return 0;
    }
    
  • -1
    @ 2017-01-07 11:36:37
        #include <iostream>
        using namespace std;
        int main()
        {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
        return 0;
        }
    
  • -1
    @ 2016-12-26 23:24:08

    #include <stdio.h>
    int main()
    {
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", a + b);
    return 0;
    }

  • -1
    @ 2016-12-14 13:15:12
    #include<cstdio>
    #include<cstring>
    #include<iostream>
    using namespace std;
    char a1[10000],b1[10000];int a[10000],b[10000],c[10000],x=0,lena,lenb,lenc=1,i;
    int main()
    {
        scanf("%s",a1);scanf("%s",b1);lena=strlen(a1);lenb=strlen(b1);
        for(i=0;i<=lena-1;i++) a[lena-i]=a1[i]-'0';
        for(i=0;i<=lenb-1;i++) b[lenb-i]=b1[i]-'0';
        while(lenc<=lena||lenc<=lenb)
        {
            c[lenc]=a[lenc]+b[lenc]+x;
            x=c[lenc]/10;
            c[lenc]%=10;
            lenc++;
        }
        if(0==(c[lenc]=x)) lenc--;
        for(i=lenc;i>=1;i--) cout<<c[i];return 0;
    }
    
  • -1
    @ 2016-12-11 18:52:57

    这道题实际上是一道最短路的模型题。我们只需要构造一个有三个顶点的无向图,1和2之间有一条边权为a的边,2和3之间有一条边权为b的边,而1和3之间有一条边权为maxlongint的边,那么答案就是1到3的最短路

信息

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