結果

問題 No.1581 Multiple Sequence
ユーザー ytqm3ytqm3
提出日時 2021-07-02 21:59:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 3,588 bytes
コンパイル時間 2,097 ms
コンパイル使用メモリ 202,444 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 21:53:13
合計ジャッジ時間 4,511 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 81 ms
4,380 KB
testcase_03 AC 89 ms
4,380 KB
testcase_04 AC 22 ms
4,376 KB
testcase_05 AC 93 ms
4,380 KB
testcase_06 AC 39 ms
4,380 KB
testcase_07 AC 21 ms
4,380 KB
testcase_08 AC 30 ms
4,376 KB
testcase_09 AC 83 ms
4,376 KB
testcase_10 AC 53 ms
4,380 KB
testcase_11 AC 11 ms
4,376 KB
testcase_12 AC 32 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 89 ms
4,380 KB
testcase_15 AC 62 ms
4,380 KB
testcase_16 AC 14 ms
4,380 KB
testcase_17 AC 100 ms
4,376 KB
testcase_18 AC 9 ms
4,376 KB
testcase_19 AC 77 ms
4,380 KB
testcase_20 AC 80 ms
4,376 KB
testcase_21 AC 88 ms
4,380 KB
testcase_22 AC 48 ms
4,376 KB
testcase_23 AC 104 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<u64 mod>
struct modint{
  u64 val;
  constexpr modint(const i64 x=0) noexcept:val((x%i64(mod)+i64(mod))%i64(mod)){}
  constexpr u64 &value() noexcept{
    return val;
  }
  constexpr modint operator+(const modint rhs) const noexcept{
    return modint(*this)+=rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept{
    return modint(*this)-=rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept{
    return modint(*this)*=rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept{
    return modint(*this)/=rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept{
    val+=rhs.val;
    val-=((val>=mod)?mod:0);
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept{
    val+=((val<rhs.val)?mod:0);
    val-=rhs.val;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept{
    val=val*rhs.val%mod;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept{
    u64 exp=mod-2;
    while(exp){
      if(exp&1){
        (*this)*=rhs;
      }
      rhs*=rhs;
      exp>>=1;
    }
    return *this;
  }
  friend constexpr ostream &operator<<(ostream &os,const modint &x) noexcept{
    return os<<(x.val);
  }
  friend constexpr istream &operator>>(istream &is,modint &x) noexcept{
    u64 t;
    is>>t;
    x=t;
    return is;
  }
};

template<typename T>
void scan(T& n){
  cin>>n;
}

void scan(){}

template<typename T,class... Args>
void scan(T& n,Args&... args){
  scan(n);
  scan(args...);
}

template<typename T>
void scanall(T start,T end){
  for(;start!=end;++start){
    scan(*start);
  }
}

template<typename T>
void print(T n){
  cout<<n;
}

void print(){}

template<typename T,class... Args>
void print(T n,Args... args){
  print(n);
  print(args...);
}

template<typename T>
void println(T n){
  print(n);
  cout<<endl;
}

template<typename T,class... Args>
void println(T n,Args... args){
  print(n,' ');
  println(args...);
}

template<typename T>
void printall(T start,T end){
  if(start!=end){
    print(*start);
    for(++start;start!=end;++start){
      print(' ',*start);
    }
  }
  cout<<endl;
}

template<typename T>
void chmax(T& n,T m){
  n=max(n,m);
}

template<typename T>
void chmin(T& n,T m){
  n=min(n,m);
}

template<typename T>
T power(T a,i64 n){
  T res=1;
  while(n){
    res*=(n&1)?a:1;
    a*=a;
    n>>=1;
  }
  return res;
}

i64 power(i64 a,i64 n,i64 m){
  i64 res=1;
  while(n){
    res=res*((n&1)?a:1)%m;
    a=a*a%m;
    n>>=1;
  }
  return res;
}

template<typename T>
struct combination{
  vector<T> fact;
  combination(const int mx=3000000):fact(mx+1,1){
    for(int i=2;i<=mx;++i){
      fact[i]=fact[i-1]*i;
    }
  }
  template<typename U>
  T nCk(U n,U k){
    if(n<k||n<0||k<0){
      return 0;
    }
    return fact[n]/fact[k]/fact[n-k];
  }
};

void solve();

int main(){
  cout<<fixed<<setprecision(15);
  bool is_multicase=false;
  int T=1;
  if(is_multicase){
    scan(T);
  }
  for(int i=0;i<T;++i){
    solve();
  }
  return 0;
}

vector<int> div_enum(int N){
  vector<int> res;
  for(int i=1;i*i<=N;++i){
    if(N%i!=0){
      continue;
    }
    res.emplace_back(i);
    if(i*i!=N){
      res.emplace_back(N/i);
    }
  }
  return res;
}

void solve(){
  typedef modint<1000000007> mint;
  int M;
  scan(M);
  vector<mint> dp(M+1);
  dp[0]=1;
  dp[1]=1;
  for(int i=2;i<=M;++i){
    vector<int> vec=div_enum(i);
    for(int x:vec){
      dp[i]+=dp[i/x-1];
    }
  }
  println(dp[M]);
}
0