QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#276740 | #4163. 地精部落 | SoyTony | 70 | 129ms | 6612kb | C++14 | 1.3kb | 2023-12-06 10:14:18 | 2023-12-06 10:14:18 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int maxn=4e5+10;
const int maxm=1e6+10;
const int mod=1e9+7;
const ull base1=233;
const ull base2=19260817;
const int maxxn=0x7fffffff;
const int minxn=-0x7fffffff;
const db inf=1e13;
const db eps=1e-8;
inline ll read(){
int x=0,w=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
while(c<='9'&&c>='0'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return x*w;
}
int n,p;
int dp[5005][5005],sum;
int ans;
int main(){
n=read(),p=read();
dp[1][1]=1;
for(int i=2;i<=n;i++){
if(i&1){
for(int j=1;j<=i;j++){
for(int k=1;k<j;k++){
dp[i][j]=(dp[i][j]+dp[i-1][k])%p;
}
}
}
else{
for(int j=1;j<=i;j++){
for(int k=j;k<=i-1;k++){
dp[i][j]=(dp[i][j]+dp[i-1][k])%p;
}
}
}
}
for(int i=1;i<=n;i++){
ans=(ans+dp[n][i])%p;
}
ans=(ans*2)%p;
printf("%d\n",ans);
return 0;
}
详细
Test #1:
score: 10
Accepted
time: 0ms
memory: 3780kb
input:
9 2811
output:
1817
result:
ok single line: '1817'
Test #2:
score: 10
Accepted
time: 0ms
memory: 3804kb
input:
10 12929
output:
10539
result:
ok single line: '10539'
Test #3:
score: 10
Accepted
time: 0ms
memory: 3872kb
input:
17 21929121
output:
7310012
result:
ok single line: '7310012'
Test #4:
score: 10
Accepted
time: 0ms
memory: 3832kb
input:
18 29121
output:
15047
result:
ok single line: '15047'
Test #5:
score: 10
Accepted
time: 6ms
memory: 4668kb
input:
200 123849291
output:
88055017
result:
ok single line: '88055017'
Test #6:
score: 10
Accepted
time: 97ms
memory: 6276kb
input:
500 182739417
output:
182278339
result:
ok single line: '182278339'
Test #7:
score: 10
Accepted
time: 129ms
memory: 6612kb
input:
550 281321834
output:
25165060
result:
ok single line: '25165060'
Test #8:
score: 0
Time Limit Exceeded
input:
2500 18239314
output:
result:
Test #9:
score: 0
Time Limit Exceeded
input:
4000 129394123
output:
result:
Test #10:
score: 0
Time Limit Exceeded
input:
4200 192340123