//aarifshuvo ``CSEJU #include <bits/stdc++.h> #define ll long long #define pb push_back #define SZ(x) ((int)(x).size()) #define scl(x) scanf("%lld", &x) #define scll(x,y) scanf("%lld %lld", &x, &y) #define all(x) (x).begin(),(x).end() #define mem(a,d) memset(a,d,sizeof a) #define REP(i,n) for(int i=0;i<n;i++) #define REV(i,n) for(int i=n-1;i>=0;i--) #define FOR(i,a,b) for(int i=a;i<=b;i++) #define pri(a) cout<<a<<endl #define prii(a,b) cout<<a<<" "<<b<<endl using namespace std; ll dp[50][4][4]; ll n; ll go(ll i, ll cur, ll prev) { if(i==n-1) { if(cur==2) return 0; else return 1; } ll &ret = dp[i][cur][prev]; if(~ret) return ret; ret = 0; if(cur==1) { ret += ( go(i+1,3,cur) + go(i+1,2,cur) ); } else if(cur==3) { ret += ( go(i+1,1,cur) + go(i+1,2,cur) ); } else if(cur==2) { if(prev==1) ret += go(i+1,3,cur); else ret += go(i+1,1,cur); } return ret; } // 1 white 2 blue 3 red int main() { scl(n); mem(dp,-1); ll ans = go(0,1,0) + go(0,3,0); printf("%lld\n", ans); return 0; }
~Be glad of life because it gives you the chance to love and to work and to play and to look at the stars.~
Thursday, June 1, 2017
URAL 1225 - Flags
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment