QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#299365#7304. Coins 2hyman00RE 1ms5484kbC++141.4kb2024-01-06 19:46:372024-01-06 19:46:38

Judging History

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

  • [2024-01-06 19:46:38]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5484kb
  • [2024-01-06 19:46:37]
  • 提交

answer

#include <bits/stdc++.h>
#define pb push_back
#define sz(a) ((int)a.size())
#define re return
#define all(a) a.begin(),a.end()
#define rept(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) rept(i,0,a)
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define debug(x) cout<<#x<<"="<<x<<"\n";
#define int long long
using namespace std;
const int MOD=998244353,INF=1000000000000000000;
template<typename T>inline void Mx(T &a,T b){a=max(a,b);}
template<typename T>inline void Mi(T &a,T b){a=min(a,b);}
inline bool is_digit(int msk,int d){re (msk>>d)&1;}
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
void FILEIO(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}
int n,L,D;
int a[16];
int cc[1000000];
void run(){
	if(n<=10)L=2520;
	else L=360360;
	D=L*3;
	rep(i,D)cc[i]=0;
	cc[0]=1;
	int sum=0;
	rept(i,1,n+1){
		int k;
		cin>>k;
		sum+=i*k;
		if(k*i<L){
			//*(1-x^{(k+1)*i})
			int y=(k+1)*i;
			for(int j=D-y;j>=0;j--)(cc[j+y]+=MOD-cc[j])%=MOD;
		}
		//*(1-x^i)^{-1}
		rep(j,D-i+1)(cc[j+i]+=cc[j])%=MOD; 
	}
	int ans=sum+1;
	rep(i,L){
		if(cc[i])continue;
		else if(cc[i+L])ans-=2;
		else if(cc[i+L+L])ans-=4;
		else ans-=(sum+L-i)/L;
//		cout<<i<<" "<<ans<<"\n";
	}
	cout<<ans<<"\n";
}
signed main()
{
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	int T=1;
//	cin>>T;
	while(cin>>n)
		run();
	re 0;
}


詳細信息

Test #1:

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

input:

3
0 1 2
3
0 2 3

output:

6
12

result:

ok 2 number(s): "6 12"

Test #2:

score: -100
Runtime Error

input:

1
0
15
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

output:

1

result: