QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#345346#4793. QnpKevin5307WA 7ms44700kbC++201.3kb2024-03-06 20:07:002024-03-06 20:07:00

Judging History

你现在查看的是最新测评结果

  • [2024-03-06 20:07:00]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:44700kb
  • [2024-03-06 20:07:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define sz(v) (int)((v).size())
using ll=long long;
using i128=__int128_t;
const ll thres=1e12+10;
vector<ll> vC[70007];
ll C(int n,int k)
{
	k=min(k,n-k);
	return k>=sz(vC[n])?thres:vC[n][k];
}
ll mul(ll a,ll b)
{
	return min((i128)(thres),(i128)(a)*b);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	for(int i=0;i<70007;i++)
	{
		vC[i].resize(min(70,i+1));
		vC[i][0]=1;
		for(int j=1;j<sz(vC[i]);j++)
			if(j==i)
				vC[i][j]=1;
			else
				vC[i][j]=min(thres,vC[i-1][j]+vC[i-1][j-1]);
	}
	int q;
	cin>>q;
	while(q--)
	{
		if(q<4000) break;
		static int c[12];
		for(int i=0;i<10;i++)
			cin>>c[i];
		ll k;
		cin>>k;
		const ll mod=1e9+7;
		ll ans=0;
		while(true)
		{
			int sum=accumulate(c,c+10,0);
			if(!sum) break;
			int cur=0;
			while(cur<10)
			{
				if(!c[cur])
				{
					cur++;
					continue;
				}
				ll ways=1;
				c[cur]--;
				int tmp=sum-1;
				for(int i=0;i<10;i++)
				{
					ways=mul(ways,C(tmp,c[i]));
					if(ways>k) break;
					tmp-=c[i];
				}
				c[cur]++;
				if(ways<k)
				{
					k-=ways;
					cur++;
				}
				else break;
			}
			ans=(ans*10+cur)%mod;
			c[cur]--;
		}
		cout<<ans<<'\n';
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 44700kb

input:

6
1 1 0 0 0 0 0 0 0 0 1
1 1 0 0 0 0 0 0 0 0 2
1 1 1 0 0 0 0 0 0 0 1
1 1 1 0 0 0 0 0 0 0 2
1 1 1 0 0 0 0 0 0 0 5
1 2 0 0 0 0 0 0 0 0 2

output:


result:

wrong answer Answer contains longer sequence [length = 6], but output contains 0 elements