結果
問題 | No.1581 Multiple Sequence |
ユーザー | rnano |
提出日時 | 2023-09-09 01:10:30 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 292 ms / 2,000 ms |
コード長 | 3,411 bytes |
コンパイル時間 | 2,275 ms |
コンパイル使用メモリ | 206,780 KB |
実行使用メモリ | 27,904 KB |
最終ジャッジ日時 | 2024-06-26 18:23:10 |
合計ジャッジ時間 | 6,679 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 224 ms
23,552 KB |
testcase_03 | AC | 251 ms
25,216 KB |
testcase_04 | AC | 60 ms
11,136 KB |
testcase_05 | AC | 263 ms
25,984 KB |
testcase_06 | AC | 106 ms
15,104 KB |
testcase_07 | AC | 57 ms
10,752 KB |
testcase_08 | AC | 79 ms
12,928 KB |
testcase_09 | AC | 235 ms
24,192 KB |
testcase_10 | AC | 147 ms
18,176 KB |
testcase_11 | AC | 27 ms
7,808 KB |
testcase_12 | AC | 87 ms
13,568 KB |
testcase_13 | AC | 4 ms
5,376 KB |
testcase_14 | AC | 249 ms
25,344 KB |
testcase_15 | AC | 172 ms
20,224 KB |
testcase_16 | AC | 35 ms
8,576 KB |
testcase_17 | AC | 283 ms
27,264 KB |
testcase_18 | AC | 22 ms
7,040 KB |
testcase_19 | AC | 217 ms
23,168 KB |
testcase_20 | AC | 229 ms
23,680 KB |
testcase_21 | AC | 249 ms
25,088 KB |
testcase_22 | AC | 133 ms
17,024 KB |
testcase_23 | AC | 292 ms
27,904 KB |
ソースコード
#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 memo[100100]; bool used[100100]; modint calc(ll m) { if(m == 0) return 1; if(used[m]) return memo[m]; vll D = divisor(m); modint ret = 0; fore(nx, D) { ret += calc(m/nx - 1); } used[m] = true; memo[m] = ret; return ret; } int main() { ll M; cin >> M; vll D = divisor(M); cout << calc(M) << endl; }