|
|
back to boardCommon BoardI have Wrong Answer on Superlong Sums. Rybak Michael, help me. You said you can give me an idea? My troubles make me go use your help. I get WA, but all my test runnings for this program were successfull. This is the source: // solution for superlong sums. version 3.0 #include <stdio.h> typedef unsigned long T; int main() { T amo, nin=0, i, j=0; unsigned int las=0, a, b; unsigned char fpr; // output in first time fpr = 2; las = 0; scanf("%d", &amo); for (i=1; i<=amo; i++) { scanf("%d", &a); scanf("%d", &b); if (a+b < 9) { if ((fpr == 0) || (las != 0)) { printf("%d", las); fpr = 0; }; // if not in first time or las<>0 for (j=1; j<=nin; j++) printf("9"); if (nin>0) fpr = 0; nin = 0; las = a+b; }; // if a+b<9 if (a+b == 9) { nin++; }; // if a+b == 9 if (a+b > 9) { printf("%d", las+1); fpr = 0;// !!!!!! for (j=1; j<=nin; j++) printf("0"); nin = 0; las = a + b - 10; }; // if a+b > 9 }; if ((fpr == 0) || (las != 0)) printf("%d", las); for (j=1; j<=nin; j++) printf("9"); return 0; } // main |
|
|