#include<cstdio> using namespace std; int main() { int m,n; while (scanf("%d%d",&m,&n)!=EOF) { if (m==0 && n==0) return 0; int ans,r,c; r=m; c=n; if (m>n) { int t=m; m=n; n=t; } if (m==1) ans=n; else if (m==2) ans =n/4*4+(n%4==1)*2+(n%4>1)*4; else ans =(m*n+1)/2; printf("%d knights may be placed on a %d row %d column board.\n",ans,r,c); } return 0; }
Friday, May 13, 2016
UVA 696 : How Many Knights -Solution
Unknown
Studying at Shahjalal University of Science and Technology, Sylhet.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment