QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#401976 | #8543. Periodic Sequence | Bronya | AC ✓ | 516ms | 6272kb | C++14 | 772b | 2024-04-29 17:55:48 | 2024-04-29 17:55:48 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,mo;
int ans[200005];
int sav[200005],sav2[200005];
int add(int u,int v){
return (u+v>=mo?u+v-mo:u+v);
}
int main(){
scanf("%d%d",&n,&mo);
int B=sqrt(n);
for(int i=1;i<=B;i++){
sav[0]=1;ans[i]=add(ans[i],1);
for(int j=1;j<=n;j++){
sav[j]=add(sav[j-1],sav[j-1]);
if(j>=i+1)sav[j]=add(sav[j],mo-sav[j-i-1]);
if(j+i<=n)ans[j+i]=add(ans[j+i],sav[j]);
}
}
for(int j=n;j>=0;j--){
if(1ll*(B+2)*j+(B+1)>n)continue;
for(int k=B+1;j*(k+1)+k<=n;k++)
sav2[j*(k+1)+k]=add(sav2[j*(k+1)+k],((j&1)?mo-1:1));
int sum=0;
for(int k=0;k<=n;k++){
sum=add(sum,sum);
sav2[k]=sum=add(sum,sav2[k]);
}
}
for(int i=1;i<=n;i++)printf("%d\n",add(ans[i],sav2[i]));
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3896kb
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: 516ms
memory: 6264kb
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: 1ms
memory: 3904kb
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: 511ms
memory: 6124kb
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: 516ms
memory: 6272kb
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: 3948kb
input:
1 998244853
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 225ms
memory: 5100kb
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: 512ms
memory: 6216kb
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