提交时间:2026-04-16 11:26:34

运行 ID: 316669

#include<bits/stdc++.h> #define lc p<<1 #define rc p<<1|1 #define ll long long #define spp(a) sort(a.begin(),a.end()) #define pll pair<ll,ll> #define mll map<ll,ll> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define eps 1e-6 double pi=3.14159265; //#define endl '\n' #define l128 __ll128 using namespace std; ll mod = 1e9+7; //template<typename U,typename V>U min(U x,const V y){return x<y?x:y;}; //template<typename U,typename V>U max(U x,const V y){return x>y?x:y;}; template<typename U,typename V>bool cmin(U &x , const V y){ return x>y?x=y,1:0;} template<typename U,typename V>bool cmax(U &x , const V y){ return x<y?x=y,1:0;} bool ifsu(ll x) { if (x == 1)return 0; for (ll i = 2; i <= sqrt(x); i++) { if (x % i == 0) { return 0; } } return 1; } ll gcd(ll x, ll y) { return y == 0 ? x : gcd(y, x % y); } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } ll qpow(ll x,ll n){ll ans=1;for(;n;n>>=1,x*=x,x%=mod)if(n&1)ans*=x,ans%=mod;return ans;} template<typename U,typename V>U qpow(U x,V n){U y(1);for(;n;n>>=1,x*=x)if(n&1)y*=x;return y;} struct ml{ ll x; ml():x(){} template<typename T>ml(T x):x((x%=mod)<0?x+mod:x){} ml inv()const{return qpow(*this,mod-2);} ml operator-()const{return ml(-x);} ml &operator+=(const ml &t){return (x+=t.x)<mod?0:x-=mod,*this;} ml &operator-=(const ml &t){return (x-=t.x)<0?x+=mod:0,*this;} ml &operator*=(const ml &t){return x=(ll)(x)*t.x%mod,*this;} ml &operator/=(const ml &t){return *this*=t.inv();} operator ll()const{return x;} bool operator==(const ml &t)const{return x==t.x;} template<typename T>ml operator+(const T &t){return ml(*this)+=t;} template<typename T>ml operator-(const T &t){return ml(*this)-=t;} template<typename T>ml operator*(const T &t){return ml(*this)*=t;} template<typename T>ml operator/(const T &t){return ml(*this)/=t;} template<typename T>friend ml operator+(const T &x,const ml &y){return ml(x)+=y;} template<typename T>friend ml operator-(const T &x,const ml &y){return ml(x)-=y;} template<typename T>friend ml operator*(const T &x,const ml &y){return ml(x)*=y;} template<typename T>friend ml operator/(const T &x,const ml &y){return ml(x)/=y;} friend istream &operator>>(istream &is,ml &t){ll x;is>>x;t=ml(x);return is;} friend ostream &operator<<(ostream &os,const ml &t){return os<<t.x;} }; void ji(){ ll n; cin>>n; array<ll,8> f={1,0,0,1,0,0,1,0},g; for(ll i=2;i<=n;i++){ g={f[7],f[6],f[5],(f[7]+f[4])%mod,f[3],f[2],(f[1]+f[7])%mod,(f[0]+f[6]+f[3])%mod}; f=g; } cout<<f[7]<<endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); ll t=1; //cin>>t; for(ll i=1;i<=t;i++)ji(); return 0; } /* COWWCOCOWWCO OWC */ /* 551097717 */