QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#104974#4793. QnpDeterminantWA 12ms7092kbC++141.4kb2023-05-12 17:54:112023-05-12 17:54:13

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-12 17:54:13]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:7092kb
  • [2023-05-12 17:54:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;typedef long long ll;
const int N=70007;const ll p=1145141919810011ll,p2=1e9+7;
int a[11],st,minn,cnt;ll pow0[N],pow1[N],ans,m,inv[N],f[N],f_[N];double s[N];
void sol(){
	ans=st=0;for(int i=0;i<10;++i)scanf("%d",&a[i]),st+=a[i];scanf("%lld",&m);
	double qz=0;for(int i=0;i<10;++i)qz-=s[a[i]];
	for(int i=0;i<10;++i)if(a[i]&&qz+s[st-a[i]]+s[a[i]]>12){
		ans=(ans*pow0[a[i]]+pow1[a[i]]*i)%p2;
		st-=a[i],qz+=s[a[i]],a[i]=0;
	}
	for(int i=0;i<10;++i)if(a[i]){minn=i;break;}
	while(st){
		int fl;if(qz>18){
			ans=(ans*10+minn)%p2;qz+=s[st-1]-s[st]+s[a[minn]]-s[a[minn]-1];
			a[minn]--;st--;
			if(!a[minn]){for(int i=0;i<10;++i)if(a[i]){minn=i;break;}}continue;
		}++cnt;
		for(int i=0;i<10;++i)if(a[i]){
			double q=s[st-1];
			for(int j=0;j<10;++j)q-=s[a[j]-(i==j)];
			if(q>14){fl=i;break;}
			ll q2=f[st-1];
			for(int j=0;j<10;++j)q2=(__int128)q2*f_[a[j]-(i==j)]%p;
			if(m<=q2){fl=i;break;}else m-=q2;
		}
		ans=(ans*10+fl)%p2;st--;a[fl]--;
	}
	return;//printf("%lld\n",ans);return;
}
int main(){
	inv[1]=1;for(int i=2;i<N;++i)inv[i]=(__int128)(p-p/i)*inv[p%i]%p;
	f[0]=f_[0]=pow0[0]=1;for(int i=1;i<N;++i){
		f[i]=(__int128)f[i-1]*i%p,f_[i]=(__int128)f[i-1]*inv[i]%p;
		s[i]=s[i-1]+log10(i);pow1[i]=(pow1[i-1]*10+1)%p2;
		pow0[i]=pow0[i-1]*10%p2;
	}
	int t;scanf("%d",&t);t=min(t,1000);while(t--)sol();cout<<cnt<<endl;return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 12ms
memory: 7092kb

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:

16

result:

wrong answer 1st numbers differ - expected: '1', found: '16'