QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#720346 | #8543. Periodic Sequence | konyakest | WA | 1264ms | 5520kb | C++17 | 1.6kb | 2024-11-07 12:03:03 | 2024-11-07 12:03:04 |
Judging History
answer
#include<bits/stdc++.h>
#define F(i,j,k) for(auto i=j;i<=(decltype(i))k;i++)
#define x first
#define y second
#define exec(...) [&](){__VA_ARGS__}()
#define endl '\n'
#define os ostream
#define pb push_back
#define view(x) begin(x),end(x)
#define lambda [&]
using namespace std;
using ll=long long;
template<typename T>void ckmin(T& x,T y){x=min(x,y);}
template<typename T>void ckmax(T& x,T y){x=max(x,y);}
#ifdef DEBUG
template<typename T1,typename T2>os& operator<<(os&,pair<T1,T2>);
template<typename T,typename=decltype(T().begin()),typename=enable_if_t<!is_same_v<decay_t<T>,string>>>os& operator<<(os& out,T x){auto n=0u;out<<"{";for(auto i:x) out<<i<<(++n==x.size()?"":",");return out<<"}";}
template<typename ...T>os& operator<<(os& out,tuple<T...> x){return apply(lambda(T... x){auto n=0u;out<<"{";((out<<x<<(++n==sizeof...(T)?"":",")),...);},x),out<<"}";}
template<typename T1,typename T2>os& operator<<(os& out,pair<T1,T2> x){return out<<tuple(x);}
#define debug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<" = "<<std::make_tuple(__VA_ARGS__)<<endl
#else
#define debug(...) (void)0
#endif
const int maxn=3e5+5,B=450;
int ans[maxn],f[maxn],n,mod;
void ge(int k){
memset(f,0,sizeof f);
f[k]=1,ans[k]++;
F(i,k+1,n) f[i]=(2ll*f[i-1]+mod-f[i-k-1])%mod,(ans[i]+=f[i])%=mod;
}
void le(int k){
int w=(k&1?mod-1:1);
for(int i=B*(k+1);i<=n;i+=k+1) (ans[i]+=w)%=mod;
F(i,1,n) ans[i]=(ans[i]+2ll*ans[i-1])%mod;
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
cin>>n>>mod;
for(int i=B;i>=0;i--) le(i);
F(i,1,B-1) ge(i);
F(i,1,n) cout<<ans[i]<<" ";
cout<<endl;
}
详细
Test #1:
score: 100
Accepted
time: 10ms
memory: 4820kb
input:
5 1000000007
output:
1 3 6 11 19
result:
ok 5 number(s): "1 3 6 11 19"
Test #2:
score: -100
Wrong Answer
time: 1264ms
memory: 5520kb
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:
wrong answer 900th numbers differ - expected: '381269230', found: '381269229'