UVA 10970 - Big Chocolate 洪水@。@
先横着切m-1刀,矩形巧克力就变成了1*n (有m个)然后每个都要切n-1下,所以有 m*(n-1) +(m-1)= n*m-1
#include<cstdio> int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF) { printf("%d\n",n*m-1); } }
新 blog : www.hrwhisper.me
先横着切m-1刀,矩形巧克力就变成了1*n (有m个)然后每个都要切n-1下,所以有 m*(n-1) +(m-1)= n*m-1
#include<cstdio> int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF) { printf("%d\n",n*m-1); } }