QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#31277 | #4007. 树 | regolulu | 60 | 885ms | 12680kb | C++ | 756b | 2022-05-06 11:40:31 | 2022-05-06 11:40:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int m,n,Mod; ll C[510][510];
//int dp[55][55][55][55];
int dp[210][210][210];
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>m>>Mod;
if (m==1){ return 0;}
for (int i=0;i<=m;i++){
C[i][0]=1;
for (int j=1;j<=i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%Mod;
}
for (int y=0;y<=m;y++)
for (int c=0;c<=m;c++)
dp[1][y][c]=y%Mod;
for (int i=2;i<=m;i++){
cout<<dp[i-1][1][1]<<'\n';
for (int y=0;y<=m;y++){
for (int c=0;c<=m;c++){
dp[i][y][c]=(dp[i][y][c]+1ll*(dp[i-1][y+1][c+1]-dp[i-1][y][c+1]+Mod)*y)%Mod;
for (int j=0;j<c;j++) dp[i][y][c]=(dp[i][y][c]+C[c][j]*dp[i-1][y][j+1]%Mod*y)%Mod;
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 10
Accepted
time: 3ms
memory: 3772kb
input:
10 577151064
output:
1 2 12 120 1928 44368 1394944 57288704 94480200
result:
ok 9 numbers
Test #2:
score: 10
Accepted
time: 4ms
memory: 4080kb
input:
20 993244853
output:
1 2 12 120 1928 44368 1394944 57288704 500961 765914688 721727386 828519746 578809878 456780398 566346177 528608756 112517275 556697045 568491469
result:
ok 19 numbers
Test #3:
score: 10
Accepted
time: 53ms
memory: 5872kb
input:
48 693389412
output:
1 2 12 120 1928 44368 1394944 57288704 206677872 93448752 311229980 378398080 125171140 600238484 463296372 561311928 329571716 372970120 613153144 269319584 39317988 650402652 168384404 534851656 34323712 215031272 571825440 276426924 452666204 65470204 266586376 160926452 211220340 374251752 67686...
result:
ok 47 numbers
Test #4:
score: 10
Accepted
time: 62ms
memory: 6112kb
input:
50 1000000021
output:
1 2 12 120 1928 44368 1394944 57288704 980235478 468922453 461761187 992820728 222191705 300367066 987453727 296887978 372555015 955448207 763668619 979367361 619326086 386572917 557116733 365169253 648460492 571297313 590441681 957006239 722930829 488988561 87845027 317417171 474978324 228338990 66...
result:
ok 49 numbers
Test #5:
score: 10
Accepted
time: 775ms
memory: 12088kb
input:
97 192608170
output:
1 2 12 120 1928 44368 1394944 57288704 91112970 16405484 80100176 70225008 48127872 176500510 39558398 22009052 21398644 141840316 189415170 192276316 116361256 72578142 52819502 188156950 188410248 176509638 32522564 83818754 28928230 65470204 73978206 122404818 134177072 66078680 21994318 88253492...
result:
ok 96 numbers
Test #6:
score: 10
Accepted
time: 885ms
memory: 12680kb
input:
100 949494599
output:
1 2 12 120 1928 44368 1394944 57288704 131751723 620512065 437266937 358823802 539191611 176844929 543845036 668141281 801642858 243456188 475342903 130532838 725579466 483897130 428695490 554394226 640052996 822143891 597926520 115217926 933551207 829213453 163959314 857759387 609179400 110139502 2...
result:
ok 99 numbers
Test #7:
score: 0
Time Limit Exceeded
input:
497 1000000008
output:
result:
Test #8:
score: 0
Time Limit Exceeded
input:
500 100000007
output:
result:
Test #9:
score: 0
Time Limit Exceeded
input:
500 996996996
output:
result:
Test #10:
score: 0
Time Limit Exceeded
input:
500 1000000009