Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int t,i,n,m,mn,x,ans;
- scanf("%d",&t);
- for(i=1;i<=t;i++){
- scanf("%d %d",&n,&m);
- mn = n*m;
- if(n==1 || m==1)
- ans = mn;
- else if(n==2 || m==2)
- {
- if(n==2)
- x = m;
- else
- x = n;
- ans = x;
- if(x%4 == 1 || x%4==3)
- ans++;
- else if(x%4==2)
- ans += 2;
- }
- else if(mn%2==0)
- ans = mn/2;
- else
- ans = (mn/2)+1;
- printf("Case %d: %d\n", i, ans);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement