結果
| 問題 |
No.1659 Product of Divisors
|
| コンテスト | |
| ユーザー |
sten_san
|
| 提出日時 | 2021-08-28 00:21:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 1,719 bytes |
| コンパイル時間 | 1,884 ms |
| コンパイル使用メモリ | 199,988 KB |
| 最終ジャッジ日時 | 2025-01-24 03:45:28 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
struct iofast_t {
iofast_t() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
} iofast;
struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
return vec(Element(), arg, args...);
}
template <typename T, typename Compare = less<T>>
T &chmin(T &l, T r, Compare &&f = less<T>()) { return l = min(l, r, f); }
template <typename T, typename Compare = less<T>>
T &chmax(T &l, T r, Compare &&f = less<T>()) { return l = max(l, r, f); }
#include <atcoder/modint>
using mint = atcoder::modint1000000007;
int main() {
int64_t n, k; cin >> n >> k;
auto pf = vec<tuple<int64_t, int>>(uns, 0);
for (int i = 2; i <= n / i; ++i) {
if (n % i != 0) {
continue;
}
int count = 0;
while (n % i == 0) {
++count;
n /= i;
}
pf.push_back({ i, count });
}
if (n != 1) {
pf.push_back({ n, 1 });
}
auto comb = [](int64_t n, int64_t r) {
mint ans = 1;
for (int i = 0; i < r; ++i) {
ans *= n - i;
}
while (r) {
ans /= r--;
}
return ans;
};
mint ans = 1;
for (auto [x, y] : pf) {
mint sub = 0;
for (int i = 0; i <= y; ++i) {
sub += comb(k + i - 1, i);
}
ans *= sub;
}
cout << ans.val() << endl;
}
sten_san