QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722527#8543. Periodic SequenceAllenJYLAC ✓1890ms6952kbC++142.6kb2024-11-07 19:25:072024-11-07 19:25:07

Judging History

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

  • [2024-11-07 19:25:07]
  • 评测
  • 测评结果:AC
  • 用时:1890ms
  • 内存:6952kb
  • [2024-11-07 19:25:07]
  • 提交

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;
int mod=1e9+7;
const int inf=1e18;
const int bs=233;
const double eps=1e-6;
const int N=2e5+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 ans[N];
int f[N];

void Main(){
    
    cin>>n>>mod;
    int B=sqrt(n);
    for(int i=1;i<=B;i++){
        ms0(f);
        f[i]=1;
        ans[i]++;
        ans[i]%=mod;
        for(int j=i+1;j<=n;j++){
            f[j]=((f[j-1]<<1)-f[j-i-1]+mod)%mod;
            (ans[j]+=f[j])%=mod;
        }
    }
    ms0(f);
    int fl=qp(mod-1,B);
    for(int i=B;~i;i--){
        for(int j=B+1;j<=n;j++){
            if((j+1)*i+j<=n)
            (f[(j+1)*i+j]+=fl)%=mod;
        }
        for(int j=1;j<=n;j++){
            f[j]=(f[j]+(f[j-1]<<1)%mod)%mod;
        }
        (fl*=mod-1)%=mod;
    }
    for(int i=1;i<=n;i++) (ans[i]+=f[i])%=mod,cout<<ans[i]<<" ";

    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;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

5 1000000007

output:

1 3 6 11 19 

result:

ok 5 number(s): "1 3 6 11 19"

Test #2:

score: 0
Accepted
time: 1890ms
memory: 6748kb

input:

200000 567894337

output:

1 3 6 11 19 33 57 100 177 317 573 1045 1919 3547 6592 12311 23091 43479 82153 155715 295983 564049 1077399 2062310 3955185 7598755 14622317 28179337 54379519 105071497 203254163 393607533 195106662 344669981 35619335 477103886 79913732 147415830 329955039 273123672 546045352 337527455 443978690 4597...

result:

ok 200000 numbers

Test #3:

score: 0
Accepted
time: 5ms
memory: 5400kb

input:

2000 1000000009

output:

1 3 6 11 19 33 57 100 177 317 573 1045 1919 3547 6592 12311 23091 43479 82153 155715 295983 564049 1077399 2062310 3955185 7598755 14622317 28179337 54379519 105071497 203254163 393607533 763000999 480458646 875091002 588152874 869906045 159506110 218346934 346224469 716986623 864678016 300921504 68...

result:

ok 2000 numbers

Test #4:

score: 0
Accepted
time: 1885ms
memory: 6940kb

input:

200000 998244853

output:

1 3 6 11 19 33 57 100 177 317 573 1045 1919 3547 6592 12311 23091 43479 82153 155715 295983 564049 1077399 2062310 3955185 7598755 14622317 28179337 54379519 105071497 203254163 393607533 763000999 482213802 878601314 596928654 887457605 196364386 290308330 486636949 990790959 401755743 350504783 12...

result:

ok 200000 numbers

Test #5:

score: 0
Accepted
time: 1883ms
memory: 6816kb

input:

200000 1000000009

output:

1 3 6 11 19 33 57 100 177 317 573 1045 1919 3547 6592 12311 23091 43479 82153 155715 295983 564049 1077399 2062310 3955185 7598755 14622317 28179337 54379519 105071497 203254163 393607533 763000999 480458646 875091002 588152874 869906045 159506110 218346934 346224469 716986623 864678016 300921504 68...

result:

ok 200000 numbers

Test #6:

score: 0
Accepted
time: 0ms
memory: 5264kb

input:

1 998244853

output:

1 

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 827ms
memory: 6152kb

input:

114514 1009999999

output:

1 3 6 11 19 33 57 100 177 317 573 1045 1919 3547 6592 12311 23091 43479 82153 155715 295983 564049 1077399 2062310 3955185 7598755 14622317 28179337 54379519 105071497 203254163 393607533 763000999 470458656 855091022 538152924 769906145 959506319 818347343 556225268 166988182 844681063 390927468 51...

result:

ok 114514 numbers

Test #8:

score: 0
Accepted
time: 1886ms
memory: 6868kb

input:

199998 500000003

output:

1 3 6 11 19 33 57 100 177 317 573 1045 1919 3547 6592 12311 23091 43479 82153 155715 295983 564049 1077399 2062310 3955185 7598755 14622317 28179337 54379519 105071497 203254163 393607533 263000996 480458649 375091005 88152886 369906072 159506173 218347057 346224709 216987088 364678928 300923295 688...

result:

ok 199998 numbers

Extra Test:

score: 0
Extra Test Passed