QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18728 | #2115. Od deski do deski [A] | koisawa | 0 | 31ms | 72188kb | C++20 | 582b | 2022-01-25 20:25:07 | 2022-05-06 02:19:09 |
Judging History
answer
#include<cstdio>
const int mod=1e9+7;
const int SIZE=3e3,MAX=SIZE+7;
int n,m,f[MAX][MAX],g[MAX][MAX];
int main () {
scanf("%d%d",&n,&m); f[1][1]=m;
for (int i=2;i<=n;i++)
for (int j=1;j<=n;j++) {
g[i][j]=((long long)f[i-1][j]*j)%mod;
if (j==m) f[i][j]=((long long)f[i-1][j]*j+(long long)g[i-1][j-1]*j)%mod;
else f[i][j]=((long long)f[i-1][j]*(m-j)+(long long)g[i-1][j-1]*(m-j))%mod;
}
int ans=0;
for (int i=1;i<=n;i++)
(ans+=g[n][i])%=mod;
printf("%d",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 1
Accepted
time: 1ms
memory: 1968kb
input:
4 2
output:
10
result:
ok single line: '10'
Test #2:
score: 0
Accepted
time: 1ms
memory: 1776kb
input:
1 1
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 1ms
memory: 2008kb
input:
1 3
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 1ms
memory: 1764kb
input:
1 5
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 1ms
memory: 1768kb
input:
2 2
output:
2
result:
ok single line: '2'
Test #6:
score: 0
Accepted
time: 1ms
memory: 1772kb
input:
2 4
output:
4
result:
ok single line: '4'
Test #7:
score: 0
Accepted
time: 1ms
memory: 2008kb
input:
3 1
output:
1
result:
ok single line: '1'
Test #8:
score: -1
Wrong Answer
time: 1ms
memory: 1768kb
input:
3 3
output:
6
result:
wrong answer 1st lines differ - expected: '9', found: '6'
Subtask #2:
score: 0
Wrong Answer
Test #20:
score: 1
Accepted
time: 1ms
memory: 1772kb
input:
1 2
output:
0
result:
ok single line: '0'
Test #21:
score: 0
Accepted
time: 1ms
memory: 1820kb
input:
1 4
output:
0
result:
ok single line: '0'
Test #22:
score: 0
Accepted
time: 1ms
memory: 1964kb
input:
2 1
output:
1
result:
ok single line: '1'
Test #23:
score: 0
Accepted
time: 1ms
memory: 2008kb
input:
2 3
output:
3
result:
ok single line: '3'
Test #24:
score: 0
Accepted
time: 1ms
memory: 1820kb
input:
2 5
output:
5
result:
ok single line: '5'
Test #25:
score: -1
Wrong Answer
time: 1ms
memory: 1876kb
input:
3 2
output:
2
result:
wrong answer 1st lines differ - expected: '4', found: '2'
Subtask #3:
score: 0
Wrong Answer
Test #37:
score: 0
Wrong Answer
time: 11ms
memory: 37448kb
input:
1689 2
output:
214122357
result:
wrong answer 1st lines differ - expected: '998472085', found: '214122357'
Subtask #4:
score: 0
Wrong Answer
Test #43:
score: 0
Wrong Answer
time: 1ms
memory: 2564kb
input:
97 83
output:
266496659
result:
wrong answer 1st lines differ - expected: '613159502', found: '266496659'
Subtask #5:
score: 0
Wrong Answer
Test #50:
score: 0
Wrong Answer
time: 12ms
memory: 21624kb
input:
1168 346407973
output:
782038523
result:
wrong answer 1st lines differ - expected: '112579949', found: '782038523'
Subtask #6:
score: 0
Wrong Answer
Test #55:
score: 0
Wrong Answer
time: 1ms
memory: 2736kb
input:
123 468402382
output:
274556173
result:
wrong answer 1st lines differ - expected: '827499041', found: '274556173'
Subtask #7:
score: 0
Wrong Answer
Test #60:
score: 0
Wrong Answer
time: 1ms
memory: 12640kb
input:
779 140176290
output:
889975585
result:
wrong answer 1st lines differ - expected: '438118426', found: '889975585'
Subtask #8:
score: 0
Wrong Answer
Test #65:
score: 0
Wrong Answer
time: 31ms
memory: 56088kb
input:
2315 21373850
output:
873973095
result:
wrong answer 1st lines differ - expected: '692830582', found: '873973095'
Subtask #9:
score: 0
Wrong Answer
Test #71:
score: 0
Wrong Answer
time: 24ms
memory: 63472kb
input:
2631 684393357
output:
996108556
result:
wrong answer 1st lines differ - expected: '936211679', found: '996108556'
Subtask #10:
score: 0
Wrong Answer
Test #77:
score: 0
Wrong Answer
time: 29ms
memory: 72188kb
input:
3000 1000000000
output:
989652933
result:
wrong answer 1st lines differ - expected: '543073891', found: '989652933'