結果
| 問題 |
No.1659 Product of Divisors
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-06-07 23:29:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 1,245 bytes |
| コンパイル時間 | 987 ms |
| コンパイル使用メモリ | 112,432 KB |
| 最終ジャッジ日時 | 2025-02-13 23:18:11 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
using namespace std;
using ll = long long;
const ll modc=1e9+7, MAX=1000000;
vector<ll> f, finv;
ll inv(ll x){
ll ans = 1, e = modc-2;
x %= modc;
while (e > 0){
if ((e & 1LL)) ans = (ans * x) % modc;
e = e >> 1LL;
x = (x*x) % modc;
}
return ans;
}
ll C(ll n, ll k){
ll ans=1;
n %= modc;
for(ll i = 0; i<k; i++) ans = ans * (n-i) % modc;
for(ll i=1; i<=k; i++) ans = (ans*inv(i)) % modc;
return ans;
}
map<ll, ll> prime;
void prime_factor(ll n){
ll m = n;
if (n % 2 == 0){
while(n % 2 == 0){
prime[2]++;
n /= 2;
}
}
for (ll i = 3; i*i <= m; i+=2){
if (n % i == 0){
while(n % i == 0){
prime[i]++;
n /= i;
}
}
}
if (n != 1){
prime[n]++;
}
}
int main(){
ll N, K, ans=1;
cin >> N >> K;
prime_factor(N);
for (auto [x, y] : prime){
ans *= C(K+y, y);
ans %= modc;
}
cout << ans << endl;
return 0;
}
srjywrdnprkt