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

求大神鉴定诡异代码、、、几乎一样的代码,一个T,一个A

Posted by justryit at 2013-09-19 16:11:35 on Problem 1942 and last updated at 2013-09-19 16:13:58
Source 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator