Tuesday, January 21, 2020

Codeforces 546A Soldier and Bananas Solution in C

  1. #include<stdio.h>
  2. int main()
  3. {
  4. int i,a,c;
  5. long int b,x=0;
  6. scanf("%d%ld%d",&a,&b,&c);
  7. for (i=1;i<=c;i++)
  8. {
  9. x=x+i*a;
  10. }
  11. if (x>b) printf("%ld\n",x-b);
  12. else printf("0\n");
  13. return 0;
  14. }

No comments:

Post a Comment

Codeforces 131A cAPS lOCK Solution in C

#include <stdio.h> int main () { char ch [ 106 ]; int i , j , ck = 1 ; scanf ( "%s" , ch ); ...