jakaria_hossain

lightoj - 1010 - Knights in Chessboard

Jul 31st, 2019
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. int main()
  5. {
  6. int t,c;
  7. cin>>t;
  8. for(c=1;c<=t;c++)
  9. {
  10. int m,n;
  11. cin>>m>>n;
  12. if(m==1)
  13. {
  14. cout<< "Case " <<c<< ": "<< n<<endl;
  15. }
  16. else if(n==1)
  17. {
  18. cout<< "Case " <<c<< ": "<< m<<endl;
  19. }
  20. else if(m==2)
  21. {
  22. m=(n/4)*4;
  23. if(n%4==1)m+=2;
  24. else if(n%4>1)m+=4;
  25. cout<< "Case " <<c<< ": "<< m<<endl;
  26. }
  27. else if(n==2)
  28. {
  29. n=(m/4)*4;
  30. if(m%4==1)n+=2;
  31. else if(m%4>1)n+=4;
  32. cout<< "Case " <<c<< ": "<< n<<endl;
  33. }
  34. else
  35. cout<< "Case " <<c<< ": "<< ((m*n)+1)/2<<endl;
  36.  
  37. }
  38. }
RAW Paste Data