QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#615245#8834. Formal Fringucup-team2432#WA 31ms11472kbC++171.9kb2024-10-05 17:55:142024-10-05 17:55:14

Judging History

This is the latest submission verdict.

  • [2024-10-05 17:55:14]
  • Judged
  • Verdict: WA
  • Time: 31ms
  • Memory: 11472kb
  • [2024-10-05 17:55:14]
  • Submitted

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define ll long long
#define all(v) v.begin(),v.end()
#define sz(v) ((ll)v.size())
#define V vector
#define vi V<int>
#define vll V<ll>
#define eb emplace_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define A array
#define pb push_back
#define mset multiset
#define gpumap __gnu_pbds::gp_hash_table
#define ccumap __gnu_pbds::cc_hash_table
#define ui unsigned int
#define ull unsigned ll
#define i128 __int128
#define cerr if (test) cerr
#define freopen if (test) freopen
#define whtest if (test)
using namespace std;

const int test = 0;

namespace jhsy {
	constexpr int P = 998244353;
	const int N = 1e6;
	A<ll,N+1> f;
	void init(const int n = N) {
		const int lg = __lg(n);
		f[0] = 1;
		for (int i = lg; i >= 0; --i) {
			int b = 1 << i;
			for (int j = b; j <= n; ++j) {
				f[j] = (f[j] + f[j - b]) % P;
			}
		}
	}
	void main() {
		auto solve = [&](int n) -> ll {
			if (n == 1) {
				return 1;
			}
			const int lg = __lg(n);
			const int a = 1<<(lg-1),b = n-a,d = (1<<lg)-1,c = n-d;
			if (max(a,c) > min(b,d)) {
				return f[n];
			}
			if (a > c) {
				return f[n-(1<<lg)];
			}
			else {
				ll res = 0;
				for (int i = lg; i >= 0; i--) {
					if ((1<<lg)-(1<<i) < c) {
						ll k = f[(1<<(lg-i))-1];
						int t = c-((1<<lg)-(1<<i));
						if (n-(n>>i<<i) <= t) {
							res = (res+k*f[n-(n>>i<<i)])%P;
						}
					}
				}
				return res;
			}
		};
		int n;
		cin >> n;
		for (int i = 1; i <= n; i++) {
			cout << solve(i) << " \n"[i == n];
		}
	}
}

int main() {
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);

	jhsy::init();

	int T = 1;
//	cin >> T;
	while (T--) {
		jhsy::main();
	}

	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 25ms
memory: 11472kb

input:

10

output:

1 1 2 1 1 3 6 1 1 2

result:

ok 10 numbers

Test #2:

score: -100
Wrong Answer
time: 31ms
memory: 11440kb

input:

70

output:

1 1 2 1 1 3 6 1 1 2 2 5 5 10 26 1 1 2 2 4 4 6 6 11 11 16 16 26 26 42 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 106 106 132 132 174 174 242 1626 1 1 2 2 4 4 6

result:

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