Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- #include<cstdlib>
- #include<cstring>
- #include<algorithm>
- #include<string>
- #include<vector>
- #include<map>
- #include<queue>
- #include<stack>
- #define loop(i, n) for(int i=0; i<n; i++)
- #define loopfrom1(i, n) for(int i=1; i<n; i++)
- #define mem(array, value) memset(array, value, sizeof(array))
- #define MIN(a, b) (a<b?a:b)
- #define MAX(a, b) (a>b?a:b)
- #define pb(a) push_back(a)
- #define SZ size()
- #define getint(n) scanf("%d", &n)
- #define pi acos(-1.0)
- #define inf 536870912 // 1<<29
- #define debug cout<<"ok"<<endl
- #define ll long long int
- #define mod(a) (a>0?a:-a)
- #define Read(filename) freopen(filename, "r", stdin)
- using namespace std;
- int f(int x)
- {
- if(x == 1) return 2;
- if(x == 2 || x == 3) return 4;
- return 0;
- }
- int main()
- {
- int x, y, z;
- while(true)
- {
- getint(x);
- getint(y);
- if(x == 0 && y == 0) break;
- if(x == 1 || y == 1)
- {
- z = x * y;
- }
- else
- {
- if(x == 2 || y == 2)
- {
- z = (x*y)/2;
- z = int(z/4) * 4 + f(z%4);
- }
- else
- {
- z = x * y;
- z = (z+1)/2;
- }
- }
- printf("%d knights may be placed on a %d row %d column board.\n",z, x, y);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement