QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#585977#8834. Formal Fring287029AC ✓70ms11428kbC++141.5kb2024-09-23 23:35:562024-09-23 23:35:57

Judging History

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

  • [2024-09-23 23:35:57]
  • 评测
  • 测评结果:AC
  • 用时:70ms
  • 内存:11428kb
  • [2024-09-23 23:35:56]
  • 提交

answer

#include <bits/stdc++.h>
#define bit(x) (1LL << (x))
#define lowbit(x) (x & (-x))
#define SQU(x) ((x) * (x))
#define ls id << 1
#define rs id << 1 | 1
//#define int long long
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const int inv2 = (mod + 1) / 2;
ll qpow(ll x,ll y) {
    ll res = 1;
    while(y) {
        if(y & 1) res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}
void add(int &x,int y) {
    x += y;
    if(x >= mod) x -= mod;
}
const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};
ll f[20],dp[maxn];
void solve() {
	int n;cin >> n;
	dp[0] = 1;
	for(int i = 1;i <= n;i <<= 1) {
		for(int j = i;j <= n;j++) {
			dp[j] = (dp[j] + dp[j - i]) % mod;
		}
	}
	for(int i = 1;i < 20;i++) {
		f[i] = dp[bit(i) - 1];
		for(int j = 1;j < i;j++) f[i] = (f[i] - f[i - j] * dp[(bit(j) - 1)] % mod + mod) % mod;
	}
	for(int i = 1;i <= n;i++) {
		int j = 0;
		while(bit(j) <= i) j += 1;
		j -= 1;
		ll ans = 0;
		int cnt = 1;
		while(i & bit(j)) {
			ans = (ans + f[cnt] * dp[i & (bit(j) - 1)] % mod) % mod;
			j -= 1;
			cnt += 1;
		}
		cout << ans << ' ';
	}
	
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    int T = 1;
//    cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}
/*
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: 70ms
memory: 11428kb

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