fork(2) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. typedef long double ld;
  5. #define rep(i,a,b) for(ll i=a;i<b;i++)
  6. #define nl cout<<endl
  7.  
  8. #define pii pair<ll,ll>
  9. #define vi vector<ll>
  10. #define vii vector<pii>
  11. #define mi map<ll,ll>
  12. #define all(a) (a).begin(),(a).end()
  13.  
  14. #define pb push_back
  15. #define ff first
  16. #define ss second
  17. #define hell 1000000007
  18.  
  19. #define test4(x,y,z,a) cout<<"x is "<<x<<" y is "<<y<<" z is "<<z<<" a is "<<a<<endl;
  20. #define test3(x,y,z) cout<<"x is "<<x<<" y is "<<y<<" z is "<<z<<endl;
  21. #define test2(x,y) cout<<"x is "<<x<<" y is "<<y<<endl;
  22. #define test1(x) cout<<"x is "<<x<<endl;
  23. #define N 300009
  24.  
  25. ll power(ll a,ll b,ll m)
  26. {
  27. ll ans=1;
  28. while(b)
  29. {
  30. if(b&1)
  31. ans=(ans*a)%m;
  32. b/=2;
  33. a=(a*a)%m;
  34. }
  35. return ans;
  36. }
  37. ll n;
  38. ll dp[N][8];
  39. ll go(ll ind,ll mask)
  40. {
  41. if(ind==(n+1))
  42. return mask==0;
  43.  
  44. if(dp[ind][mask]!=-1)
  45. return dp[ind][mask];
  46.  
  47. ll ans=0;
  48. rep(i,0,6)
  49. {
  50. ans+=go(ind+1,mask^i);
  51. ans%=hell;
  52. }
  53.  
  54. return dp[ind][mask]=ans;
  55. }
  56. int main()
  57. {
  58. ios_base::sync_with_stdio(false);
  59. cin.tie(NULL);
  60. cout.tie(NULL);
  61.  
  62. cin>>n;
  63. memset(dp,-1,sizeof(dp));
  64. cout<<go(1,0)<<endl;
  65. }
Success #stdin #stdout 0s 22364KB
stdin
Standard input is empty
stdout
1