站外题求助!
查看原帖
站外题求助!
1047309
return_second楼主2024/6/19 15:27

AC代码:

#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
int d,x,t;
bool cmb(int n,int m)
{
	int res=1;
	m=min(m,n-m);
	for(int i=0;i<m;i++)
	{
		res*=(n-i);
		res/=(i+1);
		if(res>t)
			return false;
	}
	return res<=t;
} 
signed main() 
{
	freopen("iteration.in","r",stdin);
	freopen("iteration.out","w",stdout);
	int q;
	scanf("%lld",&q);
	while(q--)
	{
		scanf("%lld%lld%lld",&d,&x,&t);
		if(cmb(x+d-1,d-1))
			puts("AC");
		else
			puts("TLE");
	} 
    return 0;
}   

WA代码:

#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
int d,x,t;
bool cmb(int n,int m)
{
	int res=1;
	m=min(m,n-m);
	for(int i=0;i<m;i++)
	{
		res*=(n-i);
		res/=(i+1);
		if(res>t)
			return false;
	}
	return true;
} 
signed main() 
{
	freopen("iteration.in","r",stdin);
	freopen("iteration.out","w",stdout);
	int q;
	scanf("%lld",&q);
	while(q--)
	{
		scanf("%lld%lld%lld",&d,&x,&t);
		if(cmb(x+d-1,d-1))
			puts("AC");
		else
			puts("TLE");
	} 
    return 0;
}   

为什么错?

2024/6/19 15:27
加载中...