Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int t, a, b, k=1, sum, d, i, c;
- scanf("%d", &t);
- while(t--){
- scanf("%d %d", &a, &b);
- c=-1, sum=0, d=0;
- for(i=1; i<=a; i++){
- sum+=(i*c);
- d++;
- if(d==b){
- d=0;
- c=c*(-1);
- }
- }
- printf("Case %d: %d\n",k, sum);
- k++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement