|
|
back to boardWA(2) for correct program ??? :( Posted by KIRILL 6 Sep 2006 02:18 program text; {$APPTYPE CONSOLE} var n,k,i,j,n1,n2,col,lastlen:integer; num1,num2:array[0..1000001] of byte; t1,t2:longword; Procedure Add; var i,carry:integer; begin carry:=0; for i:=1 to high(num1) do begin carry:=carry+num1[i]+num2[i]; if carry>=10 then begin num1[i]:=carry-10; carry:=1; end else begin num1[i]:=carry; carry:=0; end; end; end; begin { TODO -oUser -cConsole Main : Insert code here } { Assign(input,'Input.txt'); reset(input); Assign(output,'output.txt'); rewrite(output); } fillchar(num1,sizeof(num1),0); fillchar(num2,sizeof(num2),0); readln(n); col:=0; k:=0; for i:=n downto 1 do begin readln(n1,n2); num1[i]:=n1; num2[i]:=n2; end; ADD; k:=high(num1); while num1[k]=0 do dec(k); if k=0 then writeln(0) else for i:=k downto 1 do write(num1[i]); end. Re: WA(2) for correct program ??? :( Posted by AlexF 6 Sep 2006 15:36 I think you should be more careful when you read the task. Test 4 0 0 1 1 1 1 1 1 Answer 0222 And your program gives 222. Edited by author 06.09.2006 15:38 Re: WA(2) for correct program ??? :( Posted by KIRILL 7 Sep 2006 22:22 THANK YOU :) Re: WA(2) for correct program ??? :( Posted by AlexF 8 Sep 2006 15:50 You're welcome! Re: WA(2) for correct program ??? :( I have made the same mistake. Re: WA(2) for correct program ??? :( ;) Re: WA(2) for correct program ??? :( //but why me #include<bits/stdc++.h> using namespace std; int main() { long n,i,j=0; scanf("%ld",&n); int a[2000003],b=0; string s; n*=2; for(i=0;i<n;i++){ scanf("%d",&a[i]); } for(i=n-1;i>=0;i=i-2){ b=(b+a[i]+a[i-1]); s[j]=(b%10)+48; b=b/10; j++; } //if(b!=0){ //cout<<b; //} for(i=j-1;i>=0;i--){ printf("%c",s[i]); } } |
|
|