poj942Paths on a Grid

http://poj.org/problem?id=1942ios

創建數學模型 C(a,b);ide

此題就是考察排列組合 就是數據卡的緊 wa了兩次spa

 1 #include<iostream>
 2 using namespace std;
 3 int main()
 4 {
 5  unsigned long long int  n,m,s,a,b;
 6  unsigned long long int i,j;
 7     while(cin>>n>>m)
 8     {
 9         if(n==0&&m==0) break;
10         if(n<m)
11         {
12              unsigned long long int t=n;
13             n=m;
14             m=t;
15         }
16         s=1;a=n+m;b=m;
17         for(i=a-b+1,j=1;i<=a,j<=b;i++,j++)
18         {
19             s=s*i/j;
20         }
21         cout<<s<<endl;
22 
23     }
24     return 0;
25 }
View Code
相關文章
相關標籤/搜索