Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int r,c,t,result,i=0,f;
- scanf("%d",&t);
- while(t-- && scanf("%d%d",&r,&c)==2)
- {
- if(r==1 || c==1)
- {
- if(r>c)
- {
- result=r;
- }
- else
- {
- result=c;
- }
- }
- else if(r==2 || c==2)
- {
- if(r>c)
- {
- f=r;
- }
- else
- {
- f=c;
- }
- if(r==2 && c==2)
- {
- result=4;
- }
- else if(f%2==0 && f%4!=0)
- {
- result=f+2;
- }
- else if(f%2!=0)
- {
- result=f+1;
- }
- }
- else
- {
- result=ceil((float)(r*c)/2);
- }
- printf("Case %d: %d\n",++i,result);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement