Guest User

Untitled

a guest
May 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int n,m;
  5.  
  6. int main(){
  7.     cin>>n>>m;
  8.     if (n>m)
  9.         swap(n,m);
  10.     if (n==2 && m==2){
  11.         cout<<4<<endl;
  12.         return 0;
  13.     }
  14.     if (n==2 && m==3){
  15.         cout<<4<<endl;
  16.         return 0;
  17.     }
  18.     if (n==1 || m==1){
  19.         cout<<n*m<<endl;
  20.         return 0;
  21.     }
  22.     if ((n*m%2)==0)
  23.         cout<<(n*m)/2<<endl;
  24.     else
  25.         cout<<(n*m)/2+1<<endl;
  26.     return 0;
  27. }
Add Comment
Please, Sign In to add comment