QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#817105#9870. ItemsProsperityRE 424ms3836kbC++231.8kb2024-12-16 20:27:342024-12-16 20:27:36

Judging History

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

  • [2024-12-16 20:27:36]
  • 评测
  • 测评结果:RE
  • 用时:424ms
  • 内存:3836kb
  • [2024-12-16 20:27:34]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;

inline ll read(){
	ll s=0,k=1;
	char c=getchar();
	while(c>'9'||c<'0'){
		if(c=='-') k=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		s=(s<<3)+(s<<1)+(c^48);
		c=getchar();
	}
	return s*k;
}

const int mod=998244353,N=1e5+10;
int n,lgn,r[N<<2];
ll m,g,gi,lim;

ll ksm(ll a,int b){
	ll t=1;
	for(;b>0;b>>=1,a=a*a%mod)
		if(b&1) t=t*a%mod;
	return t;
}

void NTT(vector<ll> &a,bool op){
	for(int i=0;i<lim;i++) 
		if(i<r[i]) swap(a[i],a[r[i]]);
	for(int len=2;len<=a.size();len<<=1)
		for(int i=0;i<lim;i+=len){
			ll wn=ksm(op?gi:g,(mod-1)/len),w=1;
			for(int j=i;j-i<(len>>1);j++){
				ll a1=a[j],a2=a[j+(len>>1)]*w%mod;
				a[j]=a1+a2;
				if(a[j]>=mod) a[j]-=mod;
				a[j+(len>>1)]=a1-a2+mod;
				if(a[j+(len>>1)]>=mod) a[j+(len>>1)]-=mod;
				(w*=wn)%=mod;
			}
		}
	if(op){
		ll inv=ksm(lim,mod-2);
		for(int i=0;i<lim;i++) (a[i]*=inv)%=mod;
	}
}

vector<ll> operator * (vector<ll> a,vector<ll> b){
	lim=1,lgn=0;
	while(lim<a.size()+b.size()) lim<<=1,lgn++;
	for(int i=0;i<lim;i++) r[i]=r[i>>1]>>1|i%2<<lgn-1;
	a.resize(lim);b.resize(lim);
	vector<ll> c(lim);
	NTT(a,0);NTT(b,0);
	for(int i=0;i<lim;i++) c[i]=a[i]*b[i]%mod;
	NTT(c,1);
	return c;
}

vector<ll> mul(vector<ll> a,vector<ll> b){
	vector<ll> t=a*b;
	vector<ll> c(n+n+1);
	for(int i=0;i<=n+n;i++) c[i]=(t[n+i]!=0);
	return c;
}

void solve(){
	n=read();m=read();
	ll d=m/n;
	int b=n;
	vector<ll> a(n+n+1);
	vector<ll> t(n+n+1);
	for(int i=1;i<=n;i++){
		ll x=read();
		a[n+x-d]=1;
	}
	t[n]=1;
	for(;b>0;b>>=1){
		if(b&1) t=mul(t,a);	
		a=mul(a,a);
	}
	if(t[n+m%n]) puts("Yes");
	else puts("No");
}

int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	g=3;gi=ksm(3,mod-2);
	int T=read();
	while(T--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3572kb

input:

4
5 25
0 0 0 0 5
5 11
4 4 4 5 5
5 0
1 2 3 4 5
5 25
0 1 2 3 4

output:

Yes
No
No
No

result:

ok 4 token(s): yes count is 1, no count is 3

Test #2:

score: 0
Accepted
time: 41ms
memory: 3552kb

input:

1314
1 0
0
1 0
1
1 1
0
1 1
1
2 0
0 0
2 0
0 1
2 0
0 2
2 0
1 0
2 0
1 1
2 0
1 2
2 0
2 0
2 0
2 1
2 0
2 2
2 1
0 0
2 1
0 1
2 1
0 2
2 1
1 0
2 1
1 1
2 1
1 2
2 1
2 0
2 1
2 1
2 1
2 2
2 2
0 0
2 2
0 1
2 2
0 2
2 2
1 0
2 2
1 1
2 2
1 2
2 2
2 0
2 2
2 1
2 2
2 2
2 3
0 0
2 3
0 1
2 3
0 2
2 3
1 0
2 3
1 1
2 3
1 2
2 3
2 0...

output:

Yes
No
No
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
No
No
Yes
No
Yes
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
Yes
No
Yes
No
No
No
Yes
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
No
No
No
Yes
No
No
No
Yes
Yes
Yes...

result:

ok 1314 token(s): yes count is 732, no count is 582

Test #3:

score: 0
Accepted
time: 424ms
memory: 3616kb

input:

10000
4 1
0 0 0 0
4 1
0 0 0 1
4 1
0 0 0 2
4 1
0 0 0 3
4 1
0 0 0 4
4 1
0 0 1 0
4 1
0 0 1 1
4 1
0 0 1 2
4 1
0 0 1 3
4 1
0 0 1 4
4 1
0 0 2 0
4 1
0 0 2 1
4 1
0 0 2 2
4 1
0 0 2 3
4 1
0 0 2 4
4 1
0 0 3 0
4 1
0 0 3 1
4 1
0 0 3 2
4 1
0 0 3 3
4 1
0 0 3 4
4 1
0 0 4 0
4 1
0 0 4 1
4 1
0 0 4 2
4 1
0 0 4 3
4 1
0 ...

output:

No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
No
Yes
No
No
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
No
Yes
No
No
No
No
Yes
No
No
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
...

result:

ok 10000 token(s): yes count is 6168, no count is 3832

Test #4:

score: 0
Accepted
time: 86ms
memory: 3836kb

input:

1612
5 0
0 0 0 0 0
5 0
1 1 1 1 1
5 0
0 1 1 1 1
5 0
2 2 2 2 2
5 0
0 2 2 2 2
5 0
1 2 2 2 2
5 0
0 1 2 2 2
5 0
3 3 3 3 3
5 0
0 3 3 3 3
5 0
1 3 3 3 3
5 0
0 1 3 3 3
5 0
2 3 3 3 3
5 0
0 2 3 3 3
5 0
1 2 3 3 3
5 0
0 1 2 3 3
5 0
4 4 4 4 4
5 0
0 4 4 4 4
5 0
1 4 4 4 4
5 0
0 1 4 4 4
5 0
2 4 4 4 4
5 0
0 2 4 4 4
5...

output:

Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
No
No
Yes
No
No
No
Yes
No
No
No
Yes
No
No
No
Yes
No
No
No
Yes
No
No
No
Yes
No
No
No...

result:

ok 1612 token(s): yes count is 864, no count is 748

Test #5:

score: 0
Accepted
time: 247ms
memory: 3608kb

input:

4662
6 0
0 0 0 0 0 0
6 0
1 1 1 1 1 1
6 0
0 1 1 1 1 1
6 0
2 2 2 2 2 2
6 0
0 2 2 2 2 2
6 0
1 2 2 2 2 2
6 0
0 1 2 2 2 2
6 0
3 3 3 3 3 3
6 0
0 3 3 3 3 3
6 0
1 3 3 3 3 3
6 0
0 1 3 3 3 3
6 0
2 3 3 3 3 3
6 0
0 2 3 3 3 3
6 0
1 2 3 3 3 3
6 0
0 1 2 3 3 3
6 0
4 4 4 4 4 4
6 0
0 4 4 4 4 4
6 0
1 4 4 4 4 4
6 0
0 1...

output:

Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No...

result:

ok 4662 token(s): yes count is 2730, no count is 1932

Test #6:

score: -100
Runtime Error

input:

1
100000 9999999999
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 9...

output:


result: