解题思路:组合数学

1->递推:C(m,n)=c(m-1,n)+C(m,n-1),时间复杂度O(m*n)

2->组合 POJ 1942 Paths on a Grid,时间复杂度O(min(m,n))

 

代码
#include <iostream>
using namespace std;
int main()
{
__int64 i,m,n,ans;
while(scanf("%I64u %I64u", &m, &n)&&m+n)
{
if(m>n)swap(m,n);
for(ans=1,i=0;i<m;i++)
ans
=ans*(m+n-i)/(i+1);
printf(
"%I64u\n",ans);
}
return 0;
}

 

相关文章:

  • 2021-07-13
  • 2022-02-17
  • 2021-07-31
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-05-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2021-08-21
  • 2021-06-26
相关资源
相似解决方案