首页 > ACM题库 > HDU-杭电 > hdu 2621 Cry,men,not crime[解题报告]C++
2014
02-12

hdu 2621 Cry,men,not crime[解题报告]C++

Cry,men,not crime

问题描述 :

Cry,men,not crime——When I was a child ever, people around me told me not to tear. When I am a man now, I said to the mirror not to regret anything.

See the figure below,please calculate how many paths are there on a grid where each step of the path consists of moving one unit to the right or one unit up, which from left-down to right-up.


It is a simple problem, isn’t it ?
If you can’t solve it, please cry, although you are a man, nobody will laugh at you, it is not crime !

输入:

The input contains several test cases. Each is specified by two integers n and m, denoting the size of the rectangle. As you can observe, the number of lines of the corresponding grid is one more in each dimension. Input is terminated by n=m=0.

输出:

The input contains several test cases. Each is specified by two integers n and m, denoting the size of the rectangle. As you can observe, the number of lines of the corresponding grid is one more in each dimension. Input is terminated by n=m=0.

样例输入:

5 4
1 1
0 0

样例输出:

126
2


题意没看清,是32-bit unsigned integer,WA了好几次


这里就用__int64处理了


#include <stdio.h>
__int64 f(__int64 n,__int64 m){
  __int64 s=1;
  __int64 i;
  for(i=1;i<=m;i++)
  s=s*(n+i)/i;
  return s;
}
int main(){
  __int64 n,m;
  while(scanf(“%I64d %I64d”,&n,&m)!=EOF&&(n||m)){
    if(n<m){n=n^m;m=n^m;n=n^m;}
    printf(“%I64d\n”,f(n,m));}
  return 0;
}

解题转自:http://iwannacu.blog.163.com/blog/static/16284375020104455135264/


  1. “再把所有不和该节点相邻的节点着相同的颜色”,程序中没有进行不和该节点相邻的其他节点是否相邻进行判断。再说求出来的也不一样是颜色数最少的

  2. Thanks for taking the time to examine this, I really feel strongly about it and love studying a lot more on this topic. If possible, as you acquire experience