Advertisement
ismail5g

Contest

May 11th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int t, a, b, k=1, sum, d, i, c;
  5.     scanf("%d", &t);
  6.     while(t--){
  7.         scanf("%d %d", &a, &b);
  8.         c=-1, sum=0, d=0;
  9.         for(i=1; i<=a; i++){
  10.             sum+=(i*c);
  11.             d++;
  12.             if(d==b){
  13.                 d=0;
  14.                 c=c*(-1);
  15.             }
  16.         }
  17.         printf("Case %d: %d\n",k, sum);
  18.     k++;
  19.     }
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement