結果
問題 | No.890 移調の限られた旋法 |
ユーザー | kcvlex |
提出日時 | 2019-09-20 23:04:18 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 267 ms / 2,000 ms |
コード長 | 4,532 bytes |
コンパイル時間 | 1,812 ms |
コンパイル使用メモリ | 173,580 KB |
実行使用メモリ | 19,016 KB |
最終ジャッジ日時 | 2024-09-14 19:31:27 |
合計ジャッジ時間 | 12,266 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 265 ms
18,832 KB |
testcase_01 | AC | 265 ms
18,680 KB |
testcase_02 | AC | 265 ms
18,740 KB |
testcase_03 | AC | 266 ms
18,676 KB |
testcase_04 | AC | 266 ms
18,716 KB |
testcase_05 | AC | 265 ms
18,748 KB |
testcase_06 | AC | 265 ms
18,928 KB |
testcase_07 | AC | 264 ms
18,820 KB |
testcase_08 | AC | 266 ms
18,820 KB |
testcase_09 | AC | 266 ms
19,016 KB |
testcase_10 | AC | 265 ms
18,904 KB |
testcase_11 | AC | 266 ms
18,820 KB |
testcase_12 | AC | 264 ms
18,752 KB |
testcase_13 | AC | 265 ms
18,900 KB |
testcase_14 | AC | 265 ms
18,840 KB |
testcase_15 | AC | 265 ms
18,744 KB |
testcase_16 | AC | 265 ms
18,884 KB |
testcase_17 | AC | 265 ms
18,748 KB |
testcase_18 | AC | 265 ms
18,800 KB |
testcase_19 | AC | 264 ms
18,744 KB |
testcase_20 | AC | 265 ms
18,872 KB |
testcase_21 | AC | 265 ms
18,836 KB |
testcase_22 | AC | 266 ms
18,848 KB |
testcase_23 | AC | 267 ms
18,800 KB |
testcase_24 | AC | 266 ms
18,916 KB |
testcase_25 | AC | 266 ms
18,856 KB |
testcase_26 | AC | 265 ms
18,872 KB |
testcase_27 | AC | 266 ms
18,852 KB |
testcase_28 | AC | 266 ms
18,820 KB |
testcase_29 | AC | 266 ms
18,820 KB |
testcase_30 | AC | 265 ms
18,804 KB |
testcase_31 | AC | 265 ms
18,924 KB |
testcase_32 | AC | 264 ms
18,856 KB |
testcase_33 | AC | 265 ms
18,868 KB |
testcase_34 | AC | 265 ms
18,688 KB |
ソースコード
// #define DEBUGGING #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ALL(V) (V).begin(), (V).end() #define ALLR(V) (V).rbegin(), (V).rend() template <typename T> using V = vector<T>; template <typename T> using VV = V<V<T>>; using ll = int64_t; using ull = uint64_t; using PLL = pair<ll, ll>; template <typename T> const T& var_min(const T &t) { return t; } template <typename T> const T& var_max(const T &t) { return t; } template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); } template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); } template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); } template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); } namespace init__ { struct InitIO { InitIO() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(30); } } init_io; } #ifdef DEBUGGING // #include "../debug/debug.cpp" #include "../../debug/debug.cpp" #else #define DEBUG(...) 0 #define DEBUG_SEPARATOR_LINE 0 #endif template <typename T> T make_v(T init) { return init; } template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { #define rec make_v(init, tail...) return V<decltype(rec)>(s, rec); #undef rec } const ll mod = 1e9 + 7; template <ll MOD> class Combination { private: template <typename T> using V = vector<ll>; ll N; V<ll> factv, rfactv; public: /* * MOD must be a prime number. */ Combination<MOD> (ll N) : N(N), factv(N + 1, 1), rfactv(N + 1) { for(ll i = 1; i <= N; i++) { factv[i] = factv[i - 1] * i % MOD; } for(ll i = 0; i <= N; i++) { rfactv[i] = pow(factv[i], MOD - 2); } } ll fact(ll n) { return factv[n]; } ll rfact(ll n) { return rfactv[n]; } ll pow(ll a, ll b) { return b ? (b & 1 ? a : 1) * pow(a * a % MOD, b / 2) % MOD : 1; } ll comb(ll n, ll k) { return factv[n] * rfactv[n - k] % MOD * rfactv[k] % MOD; } }; Combination<mod> C(1e6 + 10); /* V<ll> primes; V<bool> used(N + 10, false); for(ll i = 2; i < N; i++) { if(used[i]) continue; primes.push_back(i); for(ll j = 1; i * j < used.size(); j++) used[i * j] = true; } */ using BS = bitset<16>; int main() { ll N, K; cin >> N >> K; ll ans = 0; V<ll> unit_lis; { ll cpy = N; for(ll i = 2; i * i <= N; i++) { ll cnt = 0; while(cpy % i == 0) { cpy /= i; cnt++; } if(cnt) unit_lis.push_back(i); } if(1 < cpy) unit_lis.push_back(cpy); } for(ll S = 1; S < (1ll << unit_lis.size()); S++) { BS bs(S); ll mul = 1; for(ll i = 0; i < unit_lis.size(); i++) if(bs.test(i)) mul *= unit_lis[i]; ll unit_size = N / mul; ll unit_cnt = N / unit_size; DEBUG(mul); if(K % unit_cnt) continue; ll val = C.comb(unit_size, K / unit_cnt); if(bs.count() % 2 == 0) val = mod - val; (ans += val) %= mod; } cout << ans << endl; return 0; } /* sort(ALL(unit_lis)); DEBUG(unit_lis); V<ll> cnt_v(N + 10, 0); for(auto unit_size : unit_lis) { for(ll i = 1; i * unit_size < cnt_v.size(); i++) { auto ite = lower_bound(ALL(unit_lis), i * unit_size); if(ite == unit_lis.end()) continue; if(*ite != i * unit_size) continue; cnt_v[i * unit_size]++; } } for(auto unit_size : unit_lis) { ll unit_cnt = N / unit_size; ll point_per_unit = K / unit_cnt; // if(unit_size < point_per_unit) continue; DEBUG(make_tuple(unit_size, unit_cnt, point_per_unit)); DEBUG(cnt_v[unit_size]); DEBUG(C.comb(unit_size, point_per_unit)); ll val = C.comb(unit_size, point_per_unit); (ans += mod + val * (cnt_v[unit_size] & 1 ? 1 : -1)) %= mod; } DEBUG(cnt_v); cout << ans << endl; return 0; } */