結果

問題 No.1811 EQUIV Ten
ユーザー ytqm3ytqm3
提出日時 2022-01-14 22:34:20
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,454 bytes
コンパイル時間 2,289 ms
コンパイル使用メモリ 202,728 KB
実行使用メモリ 35,916 KB
最終ジャッジ日時 2023-08-12 20:58:20
合計ジャッジ時間 4,562 ms
ジャッジサーバーID
(参考情報)
judge10 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 RE -
testcase_02 AC 1 ms
4,380 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 39 ms
30,232 KB
testcase_12 AC 41 ms
32,744 KB
testcase_13 AC 45 ms
34,932 KB
testcase_14 AC 46 ms
35,704 KB
testcase_15 AC 46 ms
35,916 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 3 ms
4,444 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 17 ms
13,980 KB
testcase_24 AC 5 ms
5,076 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 14 ms
12,084 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 38 ms
29,224 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 5 ms
5,564 KB
testcase_33 AC 5 ms
5,664 KB
testcase_34 AC 37 ms
28,096 KB
testcase_35 AC 13 ms
11,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
typedef uint64_t u64;
typedef int64_t i64;
using namespace std;

template<typename T> void scan_(vector<T>& a){
  for(auto& v:a){
    cin>>v;
  }
}
template<typename T> void scan_(T& a){
  cin>>a;
}
void scan(){}
template<typename T,class... Args> void scan(T& n,Args&... args){
  scan_(n),scan(args...);
}
template<typename T> void println(T n){
  cout<<n<<"\n";
}
template<typename T,class... Args> void println(T n,Args... args){
  cout<<n<<" ",println(args...);
}
template<typename T> void println(vector<T> v){
  for(size_t i=0;i<v.size();++i){
    cout<<v[i]<<" \n"[i==v.size()-1];
  }
}

template<u64 mod> struct modint{
  u64 val;
  modint(i64 val_=0):val((val_%i64(mod)+i64(mod))%i64(mod)){}
  modint operator-(){
    return (val==0)?0:mod-val;
  }
  modint operator+(modint rhs){
    return modint(*this)+=rhs;
  }
  modint operator-(modint rhs){
    return modint(*this)-=rhs;
  }
  modint operator*(modint rhs){
    return modint(*this)*=rhs;
  }
  modint operator/(modint rhs){
    return modint(*this)/=rhs;
  }
  modint operator^(i64 rhs){
    return modint(*this)^=rhs;
  }
  modint &operator+=(modint rhs){
    val+=rhs.val,val-=((val>=mod)?mod:0);
    return (*this);
  }
  modint &operator-=(modint rhs){
    val+=((val<rhs.val)?mod:0),val-=rhs.val;
    return (*this);
  }
  modint &operator*=(modint rhs){
    val=val*rhs.val%mod;
    return (*this);
  }
  modint &operator/=(modint rhs){
    return (*this)*=rhs^(mod-2);
  }
  modint &operator^=(i64 rhs){
    modint res=1,now=(*this);
    while(rhs){
      res*=((rhs&1)?now:1),now*=now,rhs>>=1;
    }
    return (*this)=res;
  }
  bool operator==(modint rhs){
    return val==rhs.val;
  }
  bool operator!=(modint rhs){
    return val!=rhs.val;
  }
  friend std::ostream &operator<<(std::ostream& os,modint x){
    return os<<(x.val);
  }
  friend std::istream &operator>>(std::istream& is,modint& x){
    u64 t;
    is>>t,x=t;
    return is;
  }
};

int main(){
  constexpr u64 mod=1000000007;
  typedef modint<mod> mint;
  int N;
  scan(N);
  if(N<4){
    println(0);
  }
  vector<vector<mint>> dp(N+1,vector<mint> (16));
  for(int j=0;j<16;++j){
    dp[4][j]=1;
  }
  for(int i=4;i<N;++i){
    for(int j=0;j<16;++j){
      if(j==10){
        continue;
      }
      dp[i+1][(2*j)%16+1]+=dp[i][j];
      dp[i+1][(2*j)%16]+=dp[i][j];
    }
  }
  mint sm=0;
  for(int j=0;j<16;++j){
    if(j!=10){
      sm+=dp[N][j];
    }
  }
  println((mint(2)^N)-sm);
}
0