QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#767100#8834. Formal FringAllenJYLAC ✓55ms34176kbC++142.6kb2024-11-20 19:50:042024-11-20 19:50:06

Judging History

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

  • [2024-11-20 19:50:06]
  • 评测
  • 测评结果:AC
  • 用时:55ms
  • 内存:34176kb
  • [2024-11-20 19:50:04]
  • 提交

answer

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

#define int long long
#define ls (p<<1)
#define rs (p<<1|1)
#define mid ((l+r)>>1)
#define all(_array) (_array).begin(),(_array).end()
#define msp(_array) memset(_array,0x3f,sizeof _array)
#define ms0(_array) memset(_array,0,sizeof _array)
#define msn(_array) memset(_array,-1,sizeof _array)
#define mc(_tar,_array) memcpy(_tar,_array,sizeof _tar)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define TAK cout<<"TAK"<<endl
#define NIE cout<<"NIE"<<endl
#define OK cerr<<"OK"<<endl
#define pii pair<int,int>
#define endl '\n'

bool bg_memory;
mt19937 rnd(time(0));
int Case=1;
const int mod=998244353;
const int inf=2147483647;
const int bs=233;
const double eps=1e-6;
const int N=2e6+7,M=1e5+7;

template<class _t1,class _t2>inline void cmax(_t1 &a,_t2 b){a=a<b?b:a;}
template<class _t1,class _t2>inline void cmin(_t1 &a,_t2 b){a=a>b?b:a;}
inline int qp(int a,int b,int p=mod){int res=1;while(b){if(b&1)res=1ll*res*a%p;a=1ll*a*a%p;b>>=1;}return res;}
inline int sqrt(int x,int r){int l=0,ans=0;while(l<=r){if(1ll*mid*mid<=x) ans=mid,l=mid+1;else r=mid-1;}return ans;}

int n;
int lg[N],g[N],dp[N];
int tot[N];
int cnt,ans;

void Main(){
    
    cin>>n;
    lg[1]=1;
    for(int i=2;i<=n;i++) lg[i]=lg[i>>1]<<1;
    dp[0]=tot[0]=1;
    for(int i=1;i<=n;i++){
        dp[i]=tot[i>>1];
        tot[i]=(tot[i-1]+dp[i])%mod;
    }
    for(int i=1;i<20;i++){
        g[i]=dp[(1<<i)-1];
        for(int j=1;j<i;j++) (g[i]+=mod-g[j]*dp[(1<<(i-j))-1]%mod)%=mod;
    }
    for(int i=1;i<=n;i++){
        int tmp=i,hi=lg[i];
        cnt=0,ans=0;
        while(hi&tmp){
            cnt++;
            tmp-=hi;
            (ans+=g[cnt]*dp[tmp]%mod)%=mod;
            hi>>=1;
        }
        cout<<ans<<' ';
    }
    cout<<endl;
    
    return;
}
string RdFile="";
bool en_memory;

signed main(){
    auto bg_clock=chrono::high_resolution_clock::now();
#ifdef ONLINE_JUDGE
    // freopen((RdFile+".in").c_str(),"r",stdin);
    // freopen((RdFile+".out").c_str(),"w",stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // cin>>Case;
    while(Case--) Main();
    auto en_clock=chrono::high_resolution_clock::now();
    auto duration_clock=chrono::duration_cast<chrono::microseconds>(en_clock-bg_clock);
    double duration_count=duration_clock.count()*0.001;
    double memory_used=(&en_memory-&bg_memory)/1024.0/1024;
    // cerr<<"Time:"<<duration_count<<"ms"<<endl;
    // cerr<<"Memory: "<<memory_used<<"MB"<<endl;
    return 0;
}

详细

Test #1:

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

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

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: 55ms
memory: 34176kb

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