QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#457860#8834. Formal Fringucup-team266#AC ✓350ms42788kbC++231.5kb2024-06-29 14:28:162024-06-29 14:28:18

Judging History

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

  • [2024-06-29 14:28:18]
  • 评测
  • 测评结果:AC
  • 用时:350ms
  • 内存:42788kb
  • [2024-06-29 14:28:16]
  • 提交

answer

/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
 
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts 
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest

9. module on time 
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pii pair<long long,long long>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
const int INF=1e18;
int n;
int dp[1000005],f[2][2000005];
const int M=1000000;
void solve()
{
	dp[0]=1;
	for(int i=0;i<20;i++) for(int j=0;j+(1<<i)<=M;j++) dp[j+(1<<i)]=(dp[j+(1<<i)]+dp[j])%mod;
	cin>>n;
	cout<<"1 ";
	for(int k=1;k<20;k++)
	{
		memset(f,0,sizeof(f));
		int nw=0;
		f[nw][1]=1;
		for(int j=k-1;j>=0;j--)
		{
			nw^=1;
			memset(f[nw],0,sizeof(f[nw]));
			for(int x=1;x<=(1<<(k+1));x++) if(f[nw^1][x]) f[nw][2*x+1]=f[nw^1][x];
			for(int x=(1<<(k+1));x>=0;x--) f[nw][x]=(f[nw][x]+f[nw][x+1])%mod;
		}
		f[nw][0]=0;
		for(int j=(1<<k);j<(1<<(k+1));j++) if(j<=n) cout<<(dp[j]-f[nw][(1<<(k+1))-1-j]+mod)%mod<<" ";
	}
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int _=1;
//	cin>>_;
	while(_--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 349ms
memory: 42788kb

input:

10

output:

1 1 2 1 1 3 6 1 1 2 

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 325ms
memory: 42732kb

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: 350ms
memory: 42684kb

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