結果

問題 No.741 AscNumber(Easy)
ユーザー CleyLCleyL
提出日時 2020-03-07 18:01:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 1,998 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 66,788 KB
実行使用メモリ 42,812 KB
最終ジャッジ日時 2024-04-23 04:59:25
合計ジャッジ時間 3,272 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
42,568 KB
testcase_01 AC 12 ms
42,716 KB
testcase_02 AC 12 ms
42,676 KB
testcase_03 AC 12 ms
42,560 KB
testcase_04 AC 12 ms
42,648 KB
testcase_05 AC 12 ms
42,600 KB
testcase_06 AC 12 ms
42,504 KB
testcase_07 AC 12 ms
42,524 KB
testcase_08 AC 12 ms
42,520 KB
testcase_09 AC 12 ms
42,516 KB
testcase_10 AC 12 ms
42,700 KB
testcase_11 AC 12 ms
42,632 KB
testcase_12 AC 13 ms
42,676 KB
testcase_13 AC 12 ms
42,656 KB
testcase_14 AC 12 ms
42,520 KB
testcase_15 AC 12 ms
42,712 KB
testcase_16 AC 12 ms
42,724 KB
testcase_17 AC 12 ms
42,632 KB
testcase_18 AC 12 ms
42,608 KB
testcase_19 AC 13 ms
42,496 KB
testcase_20 AC 12 ms
42,716 KB
testcase_21 AC 12 ms
42,664 KB
testcase_22 AC 12 ms
42,704 KB
testcase_23 AC 12 ms
42,628 KB
testcase_24 AC 12 ms
42,656 KB
testcase_25 AC 12 ms
42,640 KB
testcase_26 AC 12 ms
42,632 KB
testcase_27 AC 12 ms
42,628 KB
testcase_28 AC 12 ms
42,628 KB
testcase_29 AC 12 ms
42,780 KB
testcase_30 AC 12 ms
42,564 KB
testcase_31 AC 12 ms
42,640 KB
testcase_32 AC 13 ms
42,624 KB
testcase_33 AC 12 ms
42,568 KB
testcase_34 AC 12 ms
42,776 KB
testcase_35 AC 56 ms
42,492 KB
testcase_36 AC 31 ms
42,728 KB
testcase_37 AC 34 ms
42,632 KB
testcase_38 AC 35 ms
42,676 KB
testcase_39 AC 31 ms
42,680 KB
testcase_40 AC 38 ms
42,724 KB
testcase_41 AC 51 ms
42,620 KB
testcase_42 AC 33 ms
42,812 KB
testcase_43 AC 27 ms
42,612 KB
testcase_44 AC 42 ms
42,652 KB
testcase_45 AC 46 ms
42,796 KB
testcase_46 AC 54 ms
42,620 KB
testcase_47 AC 19 ms
42,564 KB
testcase_48 AC 54 ms
42,468 KB
testcase_49 AC 47 ms
42,532 KB
testcase_50 AC 17 ms
42,760 KB
testcase_51 AC 30 ms
42,600 KB
testcase_52 AC 58 ms
42,524 KB
testcase_53 AC 59 ms
42,632 KB
testcase_54 AC 57 ms
42,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
const int mod = 1000000007;
//B
template <int mod>
struct ModInt{
  int n;
  ModInt():n(0){}
  ModInt(int n_):n(n_ >= 0 ? n_%mod : mod - ((-n_)%mod) ){}

  ModInt &operator+=(const ModInt &p){
    if((n+=p.n) >= mod)n-=mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p){
    n+=mod-p.n;
    if(n >= mod)n-=mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p){
    n = (int) ((1LL*n*p.n)%mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p){
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const {return ModInt(-n);}
  ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}
  ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}
  ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}
  ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}

  bool operator==(const ModInt &p) const {return n==p.n;}
  bool operator!=(const ModInt &p) const {return n!=p.n;}

  ModInt inverse() const {
    int a = n,b = mod,u = 1,v = 0;
    while(b){
      int t = a/b;
      a -= t*b; swap(a,b);
      u -= t*v; swap(u,v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t z) const {
    ModInt ret(1),mul(n);
    while(z > 0){
      if(z & 1) ret *= mul;
      mul *= mul;
      z >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p){
    return os << p.n;
  }
  friend istream &operator>>(istream &is, ModInt &a){
    int64_t t;
    is >> t;
    a = ModInt<mod> (t);
    return (is);

  }
};
using mint = ModInt<mod>;
//E
mint dp[1000000][10];
int main(){
  int n;cin>>n;
  for(int i = 0; 10 > i; i++){
    dp[0][i] = 1;
  }
  for(int i = 1; n > i; i++){
    
    for(int j = 0; 10 > j; j++){
      mint a = 0;
      for(int k = 0; j >= k; k++){
        a += dp[i-1][k];
      }
      dp[i][j] = a;
    }
  }
  mint ret = 0;
  for(int i = 0; 10 > i; i++){
    ret += dp[n-1][i];
  }
  cout << ret << endl;
}
0