QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#641943 | #2934. How Many Unicycles in a Broken Wheel | faithnhope | AC ✓ | 1ms | 4016kb | C++14 | 667b | 2024-10-15 03:49:09 | 2024-10-15 03:49:09 |
Judging History
answer
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 100007;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int m; cin>>m;
long long dp2[40002] = {};
long long dp[40002] = {};
dp[2] = 1;
dp[1] = 0;
dp[3] = 5;
dp2[3] = 8;
dp2[0] = 1;
dp2[1] = 1;
dp2[2] = 3;
for (int i = 4; i <= m; i++) {
dp2[i] = (3*dp2[i-1] - dp2[i-2] ) % MOD;
dp[i] = (3*dp[i-1] - dp[i-2] + dp2[i-1]-dp2[i-2]) % MOD;
//cout<<i<<' '<<dp[i]<<' '<<dp2[i-1]<<' '<<dp3[i-1]<<endl;
}
if(dp[m-1]<0){ dp[m-1] = (dp[m-1]+MOD)%MOD;}
cout<<dp[m-1];
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4016kb
input:
5
output:
19
result:
ok single line: '19'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4012kb
input:
1234
output:
50380
result:
ok single line: '50380'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3888kb
input:
3
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
4000
output:
14774
result:
ok single line: '14774'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3960kb
input:
10
output:
5911
result:
ok single line: '5911'
Test #6:
score: 0
Accepted
time: 0ms
memory: 4012kb
input:
6
output:
65
result:
ok single line: '65'
Test #7:
score: 0
Accepted
time: 0ms
memory: 4004kb
input:
7
output:
210
result:
ok single line: '210'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
8
output:
654
result:
ok single line: '654'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
9
output:
1985
result:
ok single line: '1985'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
779
output:
59262
result:
ok single line: '59262'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
2320
output:
14502
result:
ok single line: '14502'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
768
output:
57480
result:
ok single line: '57480'
Test #13:
score: 0
Accepted
time: 0ms
memory: 4008kb
input:
2471
output:
10444
result:
ok single line: '10444'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3960kb
input:
796
output:
24011
result:
ok single line: '24011'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
3931
output:
57605
result:
ok single line: '57605'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
2508
output:
32594
result:
ok single line: '32594'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3960kb
input:
3093
output:
48868
result:
ok single line: '48868'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3976kb
input:
138
output:
64281
result:
ok single line: '64281'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
1367
output:
23969
result:
ok single line: '23969'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
2335
output:
82476
result:
ok single line: '82476'