#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll n, m, ans, dp[4][2]={1, 4, 1, 2, 1, 3, 1, 3}, temp[4];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int i, j, mod=1e9+7;
cin>>n;
for(i=2;i<n;i++)
{
temp[0]=(dp[0][1]+2*dp[1][1]%mod+dp[2][0])%mod;
temp[1]=(dp[3][0]+dp[3][1])%mod;
temp[2]=(dp[0][1]+2*dp[1][1]%mod)%mod;
temp[3]=(dp[0][1]+dp[1][1]%mod+dp[2][0])%mod;
for(j=0;j<4;j++)
{
dp[j][0]=dp[j][1];
dp[j][1]=temp[j];
}
}
cout<<dp[0][0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
476 KB |
Output is correct |
4 |
Correct |
3 ms |
508 KB |
Output is correct |
5 |
Correct |
2 ms |
540 KB |
Output is correct |
6 |
Correct |
4 ms |
668 KB |
Output is correct |
7 |
Correct |
3 ms |
668 KB |
Output is correct |
8 |
Correct |
2 ms |
668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
476 KB |
Output is correct |
4 |
Correct |
3 ms |
508 KB |
Output is correct |
5 |
Correct |
2 ms |
540 KB |
Output is correct |
6 |
Correct |
4 ms |
668 KB |
Output is correct |
7 |
Correct |
3 ms |
668 KB |
Output is correct |
8 |
Correct |
2 ms |
668 KB |
Output is correct |
9 |
Correct |
2 ms |
668 KB |
Output is correct |
10 |
Correct |
2 ms |
668 KB |
Output is correct |
11 |
Correct |
2 ms |
672 KB |
Output is correct |
12 |
Correct |
2 ms |
672 KB |
Output is correct |
13 |
Correct |
2 ms |
672 KB |
Output is correct |
14 |
Correct |
3 ms |
672 KB |
Output is correct |
15 |
Correct |
15 ms |
672 KB |
Output is correct |
16 |
Correct |
34 ms |
792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
476 KB |
Output is correct |
4 |
Correct |
3 ms |
508 KB |
Output is correct |
5 |
Correct |
2 ms |
540 KB |
Output is correct |
6 |
Correct |
4 ms |
668 KB |
Output is correct |
7 |
Correct |
3 ms |
668 KB |
Output is correct |
8 |
Correct |
2 ms |
668 KB |
Output is correct |
9 |
Correct |
2 ms |
668 KB |
Output is correct |
10 |
Correct |
2 ms |
668 KB |
Output is correct |
11 |
Correct |
2 ms |
672 KB |
Output is correct |
12 |
Correct |
2 ms |
672 KB |
Output is correct |
13 |
Correct |
2 ms |
672 KB |
Output is correct |
14 |
Correct |
3 ms |
672 KB |
Output is correct |
15 |
Correct |
15 ms |
672 KB |
Output is correct |
16 |
Correct |
34 ms |
792 KB |
Output is correct |
17 |
Correct |
82 ms |
792 KB |
Output is correct |
18 |
Correct |
221 ms |
792 KB |
Output is correct |
19 |
Correct |
314 ms |
808 KB |
Output is correct |
20 |
Correct |
632 ms |
808 KB |
Output is correct |
21 |
Correct |
691 ms |
808 KB |
Output is correct |
22 |
Execution timed out |
1078 ms |
828 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |