QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#643129 | #51. Tiling | test123 | 100 ✓ | 0ms | 3884kb | C++14 | 509b | 2024-10-15 19:04:35 | 2024-10-15 19:04:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int maxn=1005;
const int mod=1000000007;
int read(){
int ret=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
while( isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch&15);ch=getchar();}
return ret*f;
}
int n,ans;
int f[maxn],g[maxn];
int main(){
n=read();
f[0]=1;g[0]=1;
for(int i=1;i<=n;++i){
if(i>=2) f[i]=f[i-2];
f[i]=(f[i]+2ll*g[i-2])%mod;
g[i]=(g[i-2]+f[i])%mod;
}
printf("%d\n",f[n]);
return 0;
}
详细
Pretests
Final Tests
Test #1:
score: 5
Accepted
time: 0ms
memory: 3828kb
input:
1
output:
0
result:
ok single line: '0'
Test #2:
score: 5
Accepted
time: 0ms
memory: 3756kb
input:
256
output:
554759730
result:
ok single line: '554759730'
Test #3:
score: 5
Accepted
time: 0ms
memory: 3804kb
input:
36
output:
558008386
result:
ok single line: '558008386'
Test #4:
score: 5
Accepted
time: 0ms
memory: 3756kb
input:
10
output:
571
result:
ok single line: '571'
Test #5:
score: 5
Accepted
time: 0ms
memory: 3800kb
input:
46
output:
976579640
result:
ok single line: '976579640'
Test #6:
score: 5
Accepted
time: 0ms
memory: 3860kb
input:
24
output:
5757961
result:
ok single line: '5757961'
Test #7:
score: 5
Accepted
time: 0ms
memory: 3792kb
input:
202
output:
32846672
result:
ok single line: '32846672'
Test #8:
score: 5
Accepted
time: 0ms
memory: 3884kb
input:
998
output:
947883368
result:
ok single line: '947883368'
Test #9:
score: 5
Accepted
time: 0ms
memory: 3744kb
input:
98
output:
124059936
result:
ok single line: '124059936'
Test #10:
score: 5
Accepted
time: 0ms
memory: 3732kb
input:
100
output:
436252889
result:
ok single line: '436252889'
Test #11:
score: 5
Accepted
time: 0ms
memory: 3756kb
input:
200
output:
938934822
result:
ok single line: '938934822'
Test #12:
score: 5
Accepted
time: 0ms
memory: 3748kb
input:
5
output:
0
result:
ok single line: '0'
Test #13:
score: 5
Accepted
time: 0ms
memory: 3824kb
input:
18
output:
110771
result:
ok single line: '110771'
Test #14:
score: 5
Accepted
time: 0ms
memory: 3804kb
input:
2
output:
3
result:
ok single line: '3'
Test #15:
score: 5
Accepted
time: 0ms
memory: 3884kb
input:
4
output:
11
result:
ok single line: '11'
Test #16:
score: 5
Accepted
time: 0ms
memory: 3788kb
input:
6
output:
41
result:
ok single line: '41'
Test #17:
score: 5
Accepted
time: 0ms
memory: 3732kb
input:
12
output:
2131
result:
ok single line: '2131'
Test #18:
score: 5
Accepted
time: 0ms
memory: 3804kb
input:
102
output:
620951613
result:
ok single line: '620951613'
Test #19:
score: 5
Accepted
time: 0ms
memory: 3804kb
input:
16
output:
29681
result:
ok single line: '29681'
Test #20:
score: 5
Accepted
time: 0ms
memory: 3856kb
input:
378
output:
234239121
result:
ok single line: '234239121'