|
|
вернуться в форумWhy WA on test#4???? Послано Comp 15 сен 2005 23:39 #include <stdio.h> #include <string.h> int main() { long i, N; int x, y; int mas[100], uk=0, s; freopen("1048.in", "r", stdin); freopen("1048.out", "w", stdout); memset(mas, 0, sizeof(mas)); scanf("%ld", &N); scanf("%d%d", &x, &y); s=x+y; if (s > 10) { mas[uk]=s/10; mas[++uk]=s%10; } else mas[uk]=s; for (i=1; i<N; i++) { scanf("%d%d", &x, &y); s=x+y; if (s >= 10) { if (mas[uk] < 9) { mas[uk]+=s/10; mas[++uk]=s%10; } else { int p=uk; for (; p;) { if (mas[p] >= 9) mas[p]=0; else break; p--; } mas[p]+=s/10; mas[++uk]=s%10; } } else mas[++uk]=s; if (uk >= 99) { uk=1; printf("%d", mas[0]); for (int i=1; i<100; i++) mas[i-1]=mas[i]; } } for (int i=0; i<=uk; i++) printf("%d", mas[i]); fclose(stdin); fclose(stdout); return 0; } |
|
|