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 |
先对m,n排序!!然后循环较小的!!要不会TLE......#include <iostream> using namespace std; int main() { long long m,n,s; while (cin >> m >>n && m+n!=0) { if (m==0 || n==0) {cout << "1" << endl;continue;} if (m>n) {long long int temp=m;m=n;n=temp;} s=1; for (long long int i=1;i<=m;i++) s=s*(i+n)/i; cout << s << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator