|
|
вернуться в форумSolver - AC! #include <stdio.h> #include <string.h> int a[1000001],b[1000001],res[1000001],ind=0; main() { int N,i; memset (res,0,sizeof(res)); scanf("%d",&N); for (i=0;i<N;i++) scanf("%d%d",&a[i],&b[i]); for (i=N-1;i>=1;i--) { ind=(a[i]+b[i]) / 10; if (ind>0) { res[N-i]=ind; res[N-i-1]+=(a[i]+b[i]) % 10; } else res[N-1-i]+=a[i]+b[i]; if (res[N-i-1]>=10) { res[N-i]+= res[N-i-1] /10; res[N-i-1]=res[N-i-1] % 10; } } res[N-1]+=a[0]+b[0]; for(i=N-1;i>-1;i--) printf("%d",res[i]); } |
|
|