|
|
вернуться в форумWho can help me!!!!!!!!!!!!!!!!!!!!Why I got WA!!!! Послано kkk 16 апр 2002 18:51 #include<stdio.h> main() { /* freopen("a.in","r",stdin); freopen("a.out","w",stdout);*/ int a,b,k,state; long i,j; j = 0; k = 0; state=0; scanf("%ld",&i); scanf("%d%d",&a,&b); if(a+b>=10) { printf("1"); k = a + b - 10; state=1; } else if(a + b == 9) j++; else { k = a + b; state = 1; } for(;i>1;i--) { scanf("%d%d",&a,&b); if(a + b >= 10) { printf("%d",k + 1); for(;j>0;j--) printf("0"); k = a + b - 10; state = 1; } else if(a + b == 9) j++; else{ if(state) printf("%d",k); k = a + b; state = 1; for(;j>0;j--) printf("9"); } } if(state)printf("%d",k); for(; j > 0;j--) printf("9"); /* fclose(stdin); fclose(stdout);*/ } Your source is not for problem 1021... > #include<stdio.h> > main() > { > /* freopen("a.in","r",stdin); > freopen("a.out","w",stdout);*/ > int a,b,k,state; > long i,j; > j = 0; > k = 0; > state=0; > scanf("%ld",&i); > scanf("%d%d",&a,&b); > if(a+b>=10) > { > printf("1"); > k = a + b - 10; > state=1; > } > else if(a + b == 9) > j++; > else > { > k = a + b; > state = 1; > } > for(;i>1;i--) > { scanf("%d%d",&a,&b); > if(a + b >= 10) > { > printf("%d",k + 1); > for(;j>0;j--) > printf("0"); > k = a + b - 10; > state = 1; > } > else if(a + b == 9) > j++; > else{ if(state) > printf("%d",k); > k = a + b; > state = 1; > for(;j>0;j--) > printf("9"); > } > } > if(state)printf("%d",k); > for(; j > 0;j--) > printf("9"); > /* fclose(stdin); > fclose(stdout);*/ > } ...You must be dreaming now. It's the program for 1048 SUPERLONG SUM. |
|
|