QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#457301#8834. Formal Fringucup-team3510#AC ✓86ms7724kbC++14738b2024-06-29 10:17:202024-06-29 10:17:23

Judging History

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

  • [2024-06-29 10:17:23]
  • 评测
  • 测评结果:AC
  • 用时:86ms
  • 内存:7724kb
  • [2024-06-29 10:17:20]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N = 2e6 + 5, mod = 998244353;
int f[N], g[21];

int main()
{
	int n, i, j, l, ans;
	scanf("%d", &n);
	f[0] = 1;
	for(i = 0; i <= 20; i++)
		for(j = (1 << i); j <= n; j++)
			f[j] = (f[j] + f[j - (1 << i)]) % mod;
	for(i = 1; i <= 20; i++)
	{
		g[i] = f[(1 << i) - 1];
		for(j = 1; j < i; j++)
			g[i] = (g[i] + (ll)(mod - g[j]) * f[(1 << (i - j)) - 1]) % mod;
	}
	for(i = 1; i <= n; i++)
	{
		l = ans = 0;
		while(i >> (l + 1))
			l++;
		for(j = l; j >= 0; j--)
		{
			if(!((i >> j) & 1))
				break;
			ans = (ans + (ll)g[l - j + 1] * f[i & ((1 << j) - 1)]) % mod;
		}
		printf("%d ", ans);
	}
	printf("\n");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3732kb

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: 86ms
memory: 7724kb

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