QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#55433#1284. Partition NumberCrysfly#WA 90ms9932kbC++112.5kb2022-10-13 19:06:052022-10-13 19:06:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-13 19:06:07]
  • 评测
  • 测评结果:WA
  • 用时:90ms
  • 内存:9932kb
  • [2022-10-13 19:06:05]
  • 提交

answer

// what is matter? never mind. 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
//#define int long long 
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

// modint
#define mod 998244353
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 1000005
#define inf 0x3f3f3f3f

modint dp[300005],tmp[300005];

void init(int n){
	int B=sqrt(n);
	dp[0]=tmp[0]=1;
	For(i,1,B){
		For(_,0,1) For(j,i,n-i*i) tmp[j]+=tmp[j-i];
		For(j,i*i,n) dp[j]+=tmp[j-i*i];
	}
}

modint f[maxn];
void work()
{
	int n=read(),m=read();
	For(i,0,m) f[i]=dp[i];
	For(_,1,n){
		int x=read();
		Rep(i,m,x) f[i]-=f[i-x];
	}
	cout<<f[m].x<<'\n';
}

signed main()
{
	init(300005);
	int T=read();
	while(T--)work();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 90ms
memory: 9816kb

input:

5
1 4
1
1 4
2
1 4
3
3 4
1 2 3
4 4
1 2 3 4

output:

2
3
4
1
0

result:

ok 5 tokens

Test #2:

score: -100
Wrong Answer
time: 88ms
memory: 9932kb

input:

500
1 2921
832
1 1952
1842
1 1890
1711
1 2710
2136
1 1420
118
1 1427
921
1 1436
1346
1 1099
676
1 1146
75
1 1993
963
1 2819
34
1 1830
19
1 2900
1912
1 1070
993
1 2114
1434
1 2115
457
1 1407
888
1 1374
98
1 1450
555
1 2740
1469
1 2983
490
1 2209
418
1 2698
2671
1 2653
734
1 1707
1674
1 1247
527
1 147...

output:

534331308
826778795
787427970
116335786
656062179
132106757
17765543
361375797
643194883
887975470
921626129
436755061
876475876
630746069
905154023
431660970
382678132
532407817
371248392
204496571
699064370
569327593
744812919
782114486
75271714
966181965
377593956
964450666
952326515
726080378
45...

result:

wrong answer 1st words differ - expected: '656513071', found: '534331308'