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 |
求大神鉴定诡异代码、、、几乎一样的代码,一个T,一个ASource Code Problem: 1942 User: justryit Memory: N/A Time: N/A Language: C++ Result: Time Limit Exceeded Source Code #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<queue> #include<algorithm> #include<iostream> using namespace std; unsigned c(unsigned n,unsigned m) { unsigned a=m; unsigned b=n; double cnm=1.0; while(b>0) cnm*=(double)(a--)/(double)(b--); cnm+=0.5; return (unsigned)cnm; } int main() { int n=0,m=0; while(scanf("%d%d",&n,&m),!(n==0 && m==0)) { unsigned mi=min(n,m),ad=n+m; printf("%u\n",c(mi,ad)); } return 0; } Source Code Problem: 1942 User: justryit Memory: 176K Time: 0MS Language: C++ Result: Accepted Source Code #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<queue> #include<algorithm> #include<iostream> using namespace std; unsigned c(unsigned n,unsigned m) { unsigned a=m+n; unsigned b=min(n,m); double cnm=1.0; while(b>0) cnm*=(double)(a--)/(double)(b--); cnm+=0.5; return (unsigned)cnm; } int main() { int n=0,m=0; while(scanf("%d%d",&n,&m),!(n==0 && m==0)) { unsigned mi=min(n,m),ad=n+m; printf("%u\n",c(n,m)); } return 0; } 求大神鉴定,区别在于一个在main里找min,另一个在c()里找min Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator