Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int i,tcase,x,y,sum=0,m,count=0;
- scanf("%d",&tcase);
- for(m=1; m<=tcase; m++)
- {
- scanf("%d %d",&x,&y);
- if(x%2!=0)
- {
- for(i=x;; i+=2)
- {
- sum=sum+i;
- count++;
- if(count==y)
- break;
- }
- }
- else if(x%2==0)
- {
- for(i=x+1;; i+=2)
- {
- sum=sum+i;
- count++;
- if(count==y)
- break;
- }
- }
- printf("%d\n",sum);
- count=0;
- sum=0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement