题解

1330 条题解

  • 0
    @ 2013-09-07 23:16:58

    卖萌解法:
    #include <iostream>
    #include <cstdlib>
    #include <math.h>
    using namespace std;
    /* run this program using the console pauser or add your own getch, system("pause") or input loop */
    int a,b;
    double c;
    int main(int argc, char *argv[]) {
    cin>>a;
    cin>>b;
    c=pow(pow(a,2)+2*a*b+pow(b,2),0.5);
    cout<<c<<endl;
    return 0;
    }

  • 0
    @ 2013-08-31 14:02:33
  • 0
    @ 2013-08-19 14:43:13

    main(int a,int b){scanf("%d%d",&a,&b);printf("%d\n",a+b);}

  • 0
    @ 2013-08-18 23:12:38

    var
    en,et,ec,eu,ep,ex:Array[0..250000] of longint;
    dis:array[0..1000] of longint;
    v:array[0..1000] of boolean;
    i,j,k,n,m,w,cost,l:longint;
    a,b,ans,left,right:longint;

    function min(a,b:longint):longint;
    begin
    if a<b then min:=a else min:=b
    end;

    procedure addedge(s,t,c,u,k:longint);
    begin
    inc(l);
    en[l]:=en[s];
    en[s]:=l;
    et[l]:=t;
    ec[l]:=c;
    eu[l]:=u;
    ep[l]:=l+k;
    end;

    procedure build(s,t,u,c:longint);
    begin
    addedge(s,t,c,u,1);
    addedge(t,s,-c,0,-1);
    end;
    function aug(no,m:longint):longint;
    var
    i,d:longint;
    begin
    if no=n then
    begin
    inc(cost,m*dis[1]);
    exit;
    end;
    v[no]:=true;
    i:=ex[no];
    while i<>0 do
    begin
    if (eu[i]>0)and not v[et[i]] and(dis[et[i]]+ec[i]=dis[no]) then
    begin
    d:=aug(et[i],min(m,eu[i]));
    if d>0 then
    begin
    dec(eu[i],d);
    inc(eu[ep[i]],d);
    ex[no]:=i;
    exit(d);
    end;
    end;
    i:=en[i];
    end;
    ex[no]:=i;
    exit(0);
    end;

    function modlabel:boolean;
    var
    d,i,j:longint;
    begin
    d:=maxlongint;
    for i:=1 to n do
    if v[i] then
    begin
    j:=en[i];
    while j<>0 do
    begin
    if (eu[j]>0)and not v[et[j]] and(ec[j]-dis[i]+dis[et[j]]<d) then
    d:=ec[j]-dis[i]+dis[et[j]];
    j:=en[j]
    end;
    end;
    if d=maxlongint then exit(true);
    for i:=1 to n do
    if v[i] then
    begin
    v[i]:=false;
    inc(dis[i],d);
    end;
    exit(false);
    end;

    function work:longint;
    var i:longint;
    begin
    cost:=0;
    repeat
    for i:=1 to n do ex[i]:=en[i];
    while aug(1,maxlongint)>0 do
    fillchar(v,sizeof(v),0);
    until modlabel;
    work:=cost;
    end;

    function solve(x,d:longint):longint;
    var i,k,t,p,last,cost,lk:longint;
    begin
    fillchar(en,sizeof(en),0);
    fillchar(dis,sizeof(dis),0);
    k:=0; n:=2; t:=x; p:=0;
    while x<>0 do
    begin
    k:=k+x mod 10;
    x:=x div 10;
    inc(p);
    end;
    n:=1; x:=t; l:=k+p+1; last:=1; cost:=1; lk:=0;
    while x<>0 do
    begin
    k:=x mod 10;
    for i:=1 to k do
    begin
    inc(n);
    build(last,n,1,-cost);
    build(n,last+k+1,1,0);
    end;
    cost:=cost*10;
    inc(n);
    if last<>1 then
    begin
    if lk<k then
    build(1,last,k-lk,0);
    if k<lk then
    build(last,n,lk-k,0);
    end;
    last:=n; x:=x div 10;
    if lk<k then lk:=k;
    end;
    build(1,n,1,d);
    solve:=-work;
    end;

    begin
    readln(a,b);
    left:=1; right:=1000000000;
    while right-left>15000 do
    begin
    ans:=(left+right)shr 1;
    if solve(ans,b)>a then
    right:=ans
    else left:=ans;
    end;
    for i:=left to right do
    if solve(i,b)=a then
    begin
    writeln(i);
    halt;
    end;
    end.
    好难啊

  • 0
    @ 2013-08-18 23:08:45

    var
    a,b,x:longint;
    begin
    readln(a,b);
    randomize;
    repeat
    x:=random(a+b+1);
    if x=a+b then
    begin
    writeln(x);
    halt;
    end;
    until false;
    end.

    • @ 2013-11-04 21:04:41

      牛逼!!!!!!!!!

  • 0
    @ 2013-08-16 09:08:18

    #include <iostream>
    #include <algorithm>
    #include <cstdlib>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    using namespace std;
    int i,la,lb,tmp=0,x[10001],y[10001],ans[10001];
    void hplus(char a[],char b[])
    {
    la=strlen(a); lb=strlen(b); strrev(a); strrev(b);
    for(i=0;i<la;i++) if(a[i]!='-') x[i]=a[i]-48;
    for(i=0;i<lb;i++) if(b[i]!='-') y[i]=b[i]-48;
    for(i=0;i<=max(la,lb);i++){
    ans[i]=tmp+x[i]+y[i];
    tmp=ans[i]/10; ans[i]%=10;
    }
    tmp=max(la,lb);
    while(!ans[tmp] && tmp>0) tmp--;
    for(i=tmp;i>=0;i--) printf("%d",ans[i]);
    }
    void hminus(char a[],char b[])
    {
    la=strlen(a); lb=strlen(b); strrev(a); strrev(b);
    for(i=0;i<la;i++) if(a[i]!='-') x[i]=a[i]-48;
    for(i=0;i<lb;i++) if(b[i]!='-') y[i]=b[i]-48;
    for(i=0;i<=max(la,lb);i++){
    if(x[i]-y[i]<0){
    ans[i]+=((10+x[i])-y[i]);
    ans[i+1]=-1;
    }
    else ans[i]=ans[i]+(x[i]-y[i]);
    }
    tmp=max(la,lb);
    while(!ans[tmp] && tmp>0) tmp--;
    for(i=tmp;i>=0;i--) printf("%d",ans[i]);
    }
    int main()
    {
    char in1[10001],in2[10001];
    scanf("%s%s",&in1,&in2);
    if(in1[0]!='-' && in2[0]!='-') hplus(in1,in2);
    if(in1[0]=='-' && in2[0]=='-'){printf("-"); hplus(in1,in2);}
    if(in1[0]!='-' && in2[0]=='-'){
    if(abs(atoi(in1))>=abs(atoi(in2))) hminus(in1,in2);
    else{printf("-"); hminus(in2,in1);}
    }
    if(in1[0]=='-' && in2[0]!='-'){
    if(abs(atoi(in1))>=abs(atoi(in2))){printf("-"); hminus(in1,in2);}
    else hminus(in2,in1);
    }
    printf("\n");
    // system("pause");
    return 0;
    }

  • 0
    @ 2013-08-09 21:40:36

    不开longint的默默吃翔去吧

  • 0
    @ 2013-08-08 17:06:56

    #include <iostream>
    #include <cmath>
    #include <stdio.h>
    using namespace std;
    int main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
    system("pause");
    return 0;
    }

  • 0
    @ 2013-08-03 22:01:22

    其实可以随机函数 设置种子那里....处理一下

  • 0
    @ 2013-07-30 18:11:03

    评测结果
    VijosEx via JudgeDaemon2/13.7.4.0 via libjudge

    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #1: Accepted, time = 0 ms, mem = 728 KiB, score = 10

    测试数据 #2: Accepted, time = 0 ms, mem = 728 KiB, score = 10

    测试数据 #3: Accepted, time = 0 ms, mem = 728 KiB, score = 10

    测试数据 #4: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #5: Accepted, time = 0 ms, mem = 728 KiB, score = 10

    测试数据 #6: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #7: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #8: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #9: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    Accepted, time = 0 ms, mem = 732 KiB, score = 100

    纪念一下

  • 0
    @ 2013-04-04 22:39:41

    其实(a+b)应该保存成**long**型的吧。。。
    以此纪念重归vijos通过第一题~

  • 0
    @ 2013-03-18 13:18:39

    ...........................................

  • 0
    @ 2013-03-10 13:15:02

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

  • 0
    @ 2013-02-27 11:46:38

    ###高精度。。。
    #include<iostream>
    #include<cstdlib>
    #include<cstdio>
    using namespace std;
    #define max 1000
    char s1[max+10],s2[max+10];
    int a[max+10],b[max+10],ans[max+10],p;
    int main()
    {
    int i,j=0,len,t,t2,len2;
    for(i=0;i<=max;i++) {a[i]=0; b[i]=0;}
    cin>>s1>>s2;
    for(i=strlen(s1);i>=0;i--,j++) {a[j]=s1[i]-'0';}
    j=0;
    for(i=strlen(s2);i>=0;i--,j++) {b[j]=s2[i]-'0';}
    len=strlen(s1); len2=strlen(s2);
    if(len>len2) t=len;
    else t=len2;
    for(i=1;i<=t;i++) ans[i]=a[i]+b[i];
    for(p=1;p<=t;p++) if(ans[p]>9) {ans[p+1]++; ans[p]=ans[p]%10;}
    for(i=t;i>=1;i--) cout<<ans[i];
    return 0;
    }
    ###速度快了一点

  • 0
    @ 2012-11-18 10:52:51

    #include

    int main()

    {

    int a,b,s;

    do{

    scanf("%d%d",&a,&b);}

    while(a32767||b32767);

    s=a+b;

    printf("%d",s);

    return 0;

    }

  • 0
    @ 2012-11-06 17:37:50

    program n (input,output);

    var

    a,b,c: integer;

    begin

    read(a,b);

    c:=a+b;

    write(c);

    end.

  • 0
    @ 2012-11-05 12:57:29

    #include "stdio.h"

    main()

    {int a,b,sum;

    scanf("%d%d",&a,&b);

    sum=a+b;

    printf("sum=%d",sum);

    }

  • 0
    @ 2012-11-02 20:55:59

    var a,b:longint;

    begin

    readln(a,b);

    writeln(a+b);

    end.

  • 0
    @ 2012-10-31 17:17:13

    #include"stdio.h"

    int main()

    {

    int x,y,sum;

    scanf("%d%d",&x,&y);

    sum=x+y;

    printf("%d\n",sum);

    return 0;

    }

    C99标准解法~

  • 0
    @ 2012-10-29 19:26:53

    #include

    main()

    {

    int x,y,z;

    scanf("%d %d",&x,&y);

    z=x+y;

    printf("%d",z);

    }

信息

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