Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/ #include <stdio.h> int main() { int p, r, q; while(scanf("%d%d", &p, &r)!=EOF) { q = p-1; int ara[q], bnk, b, cnt=0, sum=0, i, j, nit; for(i=1; i<=r; i++) { sum = 0; scanf("%d", &bnk); scanf("%d", &b); for(j=0; j<q; j++) { scanf("%d", &ara[j]); sum += ara[j]; } if(sum>=bnk) continue; if(sum+b > bnk) b=0; nit = bnk - sum; if(bnk-sum>=10000) cnt += (10000 - b); else if((bnk-sum)>=1000) cnt += (1000 - b); else if((bnk-sum)>=100) cnt += (100 - b); else if((bnk-sum)>=10) cnt += (10 - b); else if((bnk-sum)>=1) cnt += (1- b); } printf("%d\n", cnt); } return 0; }
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.