ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1048. Superlong Sums

WA(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;

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);

col:=0;
k:=0;
for i:=n downto 1 do
begin
num1[i]:=n1;
num2[i]:=n2;
end;

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
0222

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 ??? :(
Posted by veterinarian 17 Feb 2007 08:38
I have made the same mistake.
Re: WA(2) for correct program ??? :(
Posted by AlexF [USTU] 17 Feb 2007 19:26
;)
Re: WA(2) for correct program ??? :(
Posted by abid1729 18 Jul 2019 10:03
//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]);
}
}