이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |