結果

問題 No.1581 Multiple Sequence
ユーザー rnanornano
提出日時 2023-09-09 01:15:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 3,266 bytes
コンパイル時間 2,440 ms
コンパイル使用メモリ 206,008 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 01:15:34
合計ジャッジ時間 6,291 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 201 ms
4,384 KB
testcase_03 AC 224 ms
4,384 KB
testcase_04 AC 51 ms
4,384 KB
testcase_05 AC 235 ms
4,380 KB
testcase_06 AC 93 ms
4,380 KB
testcase_07 AC 48 ms
4,380 KB
testcase_08 AC 69 ms
4,380 KB
testcase_09 AC 209 ms
4,376 KB
testcase_10 AC 129 ms
4,380 KB
testcase_11 AC 23 ms
4,380 KB
testcase_12 AC 76 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 225 ms
4,384 KB
testcase_15 AC 154 ms
4,380 KB
testcase_16 AC 29 ms
4,380 KB
testcase_17 AC 254 ms
4,376 KB
testcase_18 AC 19 ms
4,380 KB
testcase_19 AC 193 ms
4,376 KB
testcase_20 AC 203 ms
4,384 KB
testcase_21 AC 223 ms
4,376 KB
testcase_22 AC 115 ms
4,380 KB
testcase_23 AC 261 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,a,b) for (int i = a; i < b; ++i)
#define rRep(i,a,b) for (int i = a; i > b; --i)
#define fore(i,a) for(auto &i:a)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define Unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define Bit(x,i) (((x)>>(i))&1)
#define fi first
#define se second
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T, size_t n, size_t idx = 0> auto mvec(const size_t (&d)[n], const T& init) noexcept { if constexpr (idx < n) return std::vector(d[idx], mvec<T, n, idx + 1>(d, init)); else return init; }
template<class T, size_t n> auto mvec(const size_t (&d)[n]) noexcept { return mvec(d, T{}); }
void print(){ cout << '\n'; }
template<class T, class... Ts> void print(const T& a, const Ts&... b){ cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; }
template<class... T> constexpr auto Min(T... a){ return min(initializer_list<common_type_t<T...>>{a...}); }
template<class... T> constexpr auto Max(T... a){ return max(initializer_list<common_type_t<T...>>{a...}); }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
struct settings{ settings(){ ios_base::sync_with_stdio(0); cin.tie(0); cout<<fixed<<setprecision(15); }; }settingss;
const double PI = acos(-1);
const int INF = 1001001001;
const ll LINF = 1001001001001001001LL;

const int mod = 1000000007;
class modint {
  long long x;
public:
  modint(long long x=0) : x((x%mod+mod)%mod) {}
  modint operator-() const {
    return modint(-x);
  }
  modint& operator+=(const modint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  modint& operator-=(const modint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  modint& operator*=(const  modint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  modint operator+(const modint& a) const {
    modint res(*this);
    return res+=a;
  }
  modint operator-(const modint& a) const {
    modint res(*this);
    return res-=a;
  }
  modint operator*(const modint& a) const {
    modint res(*this);
    return res*=a;
  }
  modint pow(ll t) const {
    if (!t) return 1;
    modint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  modint inv() const {
    return pow(mod-2);
  }
  modint& operator/=(const modint& a) {
    return (*this) *= a.inv();
  }
  modint operator/(const modint& a) const {
    modint res(*this);
    return res/=a;
  }
  friend ostream& operator<<(ostream& os, const modint& m){
    os << m.x;
    return os;
  }
};

vector<long long> divisor(long long n) {
  vector<long long> ret;
  for (ll i = 1; 1LL*i*i <= n; i++) if (n%i == 0) { ret.push_back(i); if (i*i != n) ret.push_back(n / i); }
  sort(ret.begin(), ret.end());
  return ret;
}

modint dp[100100];

int main() {
  int M; cin >> M;
  dp[0] = 1;
  Rep(i, 1, M+1) {
    vll D = divisor(i);
    fore(d, D) {
      dp[i] += dp[i/d - 1];
    }
  }
  cout << dp[M] << endl;
}
0