Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main()
- {
- int t,c;
- cin>>t;
- for(c=1;c<=t;c++)
- {
- int m,n;
- cin>>m>>n;
- if(m==1)
- {
- cout<< "Case " <<c<< ": "<< n<<endl;
- }
- else if(n==1)
- {
- cout<< "Case " <<c<< ": "<< m<<endl;
- }
- else if(m==2)
- {
- m=(n/4)*4;
- if(n%4==1)m+=2;
- else if(n%4>1)m+=4;
- cout<< "Case " <<c<< ": "<< m<<endl;
- }
- else if(n==2)
- {
- n=(m/4)*4;
- if(m%4==1)n+=2;
- else if(m%4>1)n+=4;
- cout<< "Case " <<c<< ": "<< n<<endl;
- }
- else
- cout<< "Case " <<c<< ": "<< ((m*n)+1)/2<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement