您的位置:首页 > 其它

joj1445 棋盘上最多放多少马

2010-07-23 23:29 190 查看
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
//freopen("aaa.txt","r",stdin);
//freopen("1.txt","w",stdout);
int x,y;
while(cin>>x>>y)
{
int row=x,col=y;
if(x==0&&y==0) break;
int r=0;
if(x>y) swap(x,y);
if (x==2)
{
if(y%4==0) r=y;
else if(y%4==2) r=y+2;
else r=y+1;
}
else if(x==1) r=y;
else r=(x*y+1)/2;
printf("%d knights may be placed on a %d row %d column board./n",r,row,col);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: