QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#767139#8834. Formal FringeastcloudAC ✓133ms11456kbC++171.7kb2024-11-20 19:55:022024-11-20 19:55:03

Judging History

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

  • [2024-11-20 19:55:03]
  • 评测
  • 测评结果:AC
  • 用时:133ms
  • 内存:11456kb
  • [2024-11-20 19:55:02]
  • 提交

answer


#include<bits/stdc++.h>

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define cpy(x,y,s) memcpy(x,y,sizeof(x[0])*(s))
#define mset(x,v,s) memset(x,v,sizeof(x[0])*(s))
#define all(x) begin(x),end(x)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ary array
#define eb emplace_back
#define IL inline

using namespace std;

#define N 1000005
#define mod 998244353

IL int pls(int x,int y){return (x+y>=mod?x+y-mod:x+y);}
IL int sub(int x,int y){return (x-y<0?x-y+mod:x-y);}
IL void Add(int &x,int y){x=pls(x,y);}
IL void Dec(int &x,int y){x=sub(x,y);}
IL int mul(int x,int y){return x*1ll*y%mod;}

int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9')f=(ch=='-'?-1:f),ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return x*f;
}
void write(int x){
    if(x<0)x=-x,putchar('-');
    if(x/10)write(x/10);
    putchar(x%10+'0');
}

int f[N],g[N];

int hb(int x){return (x==0?-1:__lg(x));}

int main(){
    #ifdef EAST_CLOUD
    freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    #endif

    int n=read();
    f[0]=1;g[0]=1;
    for(int k=1;k<=n;k<<=1)for(int i=1;i<=n;i++)if(i>=k)Add(f[i],f[i-k]);
    for(int i=1;i<=n;i++){
        for(int k=1;k<=n;k<<=1){
            if(i<2*k)continue;
            if((i-2*k)%k!=0)continue;
            Add(g[i],mul(f[k],g[(i-2*k)/k]));
        }
    }
    for(int i=1;i<=n;i++){
        int ans=0;
        for(int k=0;(1<<k)<=i;k++){
            int rem=(1<<k)-(i%(1<<k));
            if(hb(i-rem)==hb(i+rem))continue;
            Add(ans,mul(f[i%(1<<k)],g[i/(1<<k)-1]));
        }
        write(ans);putchar(' ');
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10

output:

1 1 2 1 1 3 6 1 1 2 

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 1ms
memory: 5620kb

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: 133ms
memory: 11456kb

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