ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1048. Superlong Sums

Why WA#2??????
Posted by sokol[TSOGU] 7 May 2009 00:37
Why WA#2??????

#include<stdio.h>

int main(){
int* a=new int[1000005];
int* b=new int[1000005];
long n,c=0,d=0,e=0;
scanf("%d",&n);

for(int i=1;i<=n;i++){
scanf("%d %d",&a[i],&b[i]);}


for(int i=1;i<=n;i++){
        c=(c+a[i])*10;
        d=(d+b[i])*10;}

c=c/10;
d=d/10;
e=c+d;


printf("%d",e);
        }

Re: Why WA#2??????
Posted by Sergey Lazarev (MSU TB) 7 May 2009 02:00
First: if you want to get number from digits you should write
for (int i=1; i<=n; i++)
{
  c = c*10 + a[i];
  d = d*10 + b[i];
}

Second: you can't get number from such amount of digits. You should sum given numbers by digits (столбиком).

Edited by author 07.05.2009 02:03

Edited by author 07.05.2009 02:03