QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#698562#8834. Formal Fringicpc_zhzx034#WA 1ms5788kbC++14857b2024-11-01 20:31:162024-11-01 20:31:16

Judging History

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

  • [2024-11-01 20:31:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5788kb
  • [2024-11-01 20:31:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 1e6 + 5;
const ll mod = 998244353;

ll n, f[N], g[N];

inline void addmod(ll &x) {
	(x >= mod) && (x -= mod);
}

int main() {
	#ifdef LOCAL
		assert(freopen("test.in", "r", stdin));
		assert(freopen("test.out", "w", stdout));
	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	cin >> n;
	g[0] = 1;
	for (int i = 1; i <= n; i <<= 1) {
		for (int j = i; j <= n; ++j) {
			addmod(g[j] += g[j - i]);
		}
	}
	f[1] = 1;
	for (int i = 2; i <= n; ++i) {
		int j = __builtin_clz(i) ^ 31;
		f[i] = g[i ^ (1 << j)];
		if (i & (1 << (j - 1))) {
			addmod(f[i] += f[i ^ (1 << j)]);
		}
		if (!(i & (i + 1))) {
			f[i] = g[i];
		}
	}
	for (int i = 1; i <= n; ++i) {
		cout << f[i] << " ";
	}
	cout << "\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10

output:

1 1 2 1 1 3 6 1 1 2 

result:

ok 10 numbers

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5788kb

input:

70

output:

1 1 2 1 1 3 6 1 1 2 2 5 5 9 26 1 1 2 2 4 4 6 6 11 11 16 16 25 25 35 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 105 105 130 130 165 165 201 1626 1 1 2 2 4 4 6 

result:

wrong answer 14th numbers differ - expected: '11', found: '9'