QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#459945#8834. Formal FringKevin5307AC ✓228ms19432kbC++231.7kb2024-06-30 17:18:242024-06-30 17:18:35

Judging History

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

  • [2024-06-30 17:18:35]
  • 评测
  • 测评结果:AC
  • 用时:228ms
  • 内存:19432kb
  • [2024-06-30 17:18:24]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
const ll mod=998244353;
ll f[1001000];
ll s[1001000];
ll ans[1001000];
ll val[21];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	f[0]=s[0]=1;
	for(int i=1;i<=n;i++)
	{
		f[i]=s[i/2];
		s[i]=s[i-1]+f[i];
		s[i]%=mod;
	}
	for(int i=1;i<=19;i++)
		val[i]=f[(1<<i)-1];
	for(int i=1;i<=n;i++)
	{
		if(i==1)
		{
			cout<<"1 ";
			continue;
		}
		vector<int> label;
		int x=__lg(i);
		for(int j=x;j>=0;j--)
			label.pb(i>>j&1);
		int p=0;
		while(p<sz(label)&&label[p]) p++;
		vector<ll> dp(p+1);
		vector<int> vv(p+1);
		for(int i=p;i<sz(label);i++)
			if(label[i])
				vv[p]^=(1<<(sz(label)-i-1));
		for(int i=p;i;i--)
			vv[i-1]=vv[i]^(1<<(sz(label)-i));
		dp[0]=1;
		ll tot=0;
		for(int i=0;i<=p;i++)
			for(int j=i+1;j<=p;j++)
				dp[j]=(dp[j]+mod-dp[i]*val[j-i]%mod)%mod;
		for(int i=1;i<=p;i++)
			tot=(tot+dp[i]*f[vv[i]])%mod;
		cout<<(mod-tot)%mod<<' ';
	}
	return 0;
}
/*
6
1 1 1 1 1 1
1 1 1 1 2
1 1 2 2
2 2 2
1 1 4
2 4
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 7572kb

input:

10

output:

1 1 2 1 1 3 6 1 1 2 

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 7648kb

input:

70

output:

1 1 2 1 1 3 6 1 1 2 2 5 5 11 26 1 1 2 2 4 4 6 6 11 11 16 16 27 27 53 166 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 37 37 48 48 64 64 80 80 107 107 134 134 187 187 353 1626 1 1 2 2 4 4 6 

result:

ok 70 numbers

Test #3:

score: 0
Accepted
time: 228ms
memory: 19432kb

input:

1000000

output:

1 1 2 1 1 3 6 1 1 2 2 5 5 11 26 1 1 2 2 4 4 6 6 11 11 16 16 27 27 53 166 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 37 37 48 48 64 64 80 80 107 107 134 134 187 187 353 1626 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 36 36 46 46 60 60 74 74 94 94 114 114 140 140 166 166 203 203 240 240 288 288 336 336 400 ...

result:

ok 1000000 numbers

Extra Test:

score: 0
Extra Test Passed