QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#406513 | #8543. Periodic Sequence | xiaolang | TL | 1ms | 3824kb | C++14 | 526b | 2024-05-07 13:08:20 | 2024-05-07 13:08:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e3+5;
int n,MOD;
int d[N][N];
signed main(){
scanf("%lld%lld",&n,&MOD);
for(int i=1;i<=n;i++)d[0][i]=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
for(int k=1;k<=j;k++){
if(i>=k)d[i][j]=(d[i][j]+d[i-k][j])%MOD;
}
}
}
int tot=0;
for(int i=1;i<=n;i++){
int ans=0;
for(int j=1;j<=min(n,i);j++){
ans=(ans+d[i-j][j])%MOD;
}
tot=(tot+ans)%MOD;
cout<<tot<<" ";
}
cout<<"\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3824kb
input:
5 1000000007
output:
1 3 6 11 19
result:
ok 5 number(s): "1 3 6 11 19"
Test #2:
score: -100
Time Limit Exceeded
input:
200000 567894337