Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 那位大牛能解释这个问题，俩个非常相似的程序，一个ac（0ms），一个tle！！！

Posted by 2004huangyimin at 2006-04-25 14:08:21 on Problem 1942
```Source

Problem Id:1942  User Id:2004huangyimin
Memory:48K  Time:1015MS
Language:C++  Result:Time Limit Exceed

Source

#include < iostream >
using namespace std;
unsigned int com (unsigned int n,unsigned int m)
{
double i;
double result(1);
if ( n >= m - n ){ n = m-n; }
for ( i = m;i >= m-n+1;i-=1 )
{
result *= (i / (i - (m - n)));
}
return result;
}
int main()
{
unsigned int n,m;
while (1)
{
scanf("%d%d",&n,&m);
if ( n==0 && m==0 ){ break; }
printf("%d\n",com (n,m+n));
}
return 0;
}

Source

Problem Id:1942  User Id:2004huangyimin
Memory:56K  Time:0MS
Language:C++  Result:Accepted

Source

#include < iostream >
using namespace std;
double com (double n,double m)
{
double i;
double result(1);
if ( n >= m - n ){ n = m-n; }
for ( i = m;i >= m-n+1;i-=1 )
{
result *= (i / (i - (m - n)));
}
return result;
}
int main()
{
double n,m;
while (1)
{
scanf("%lf%lf",&n,&m);
if ( n==0 && m==0 ){ break; }
printf("%.0lf\n",com (n,m+n));
}
return 0;
}

```

Followed by: