Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
long long 完破~#include <iostream> using namespace std; long long gcd(long long a, long long b) { long long m = a>b?a:b; long long n = a>b?b:a; if(n==0) return m; else if(m%n==0) return n; else return gcd(n,m%n); } long long C(long long m, long long sum) { long long result = 1; if(m<sum-m) m = sum - m; for(long long i = sum;i>=m+1;i--) { long long temp = gcd(i,sum-i+1); result /= (sum-i+1) / temp; result *= i/temp; } return result; } int main() { long long m,n; while(1) { cin >> m >> n; if(m==0 && n==0) break; cout << C(m,m+n) << endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator