結果
| 問題 |
No.1659 Product of Divisors
|
| コンテスト | |
| ユーザー |
ytft
|
| 提出日時 | 2021-08-30 12:52:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 1,027 bytes |
| コンパイル時間 | 5,691 ms |
| コンパイル使用メモリ | 399,284 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-23 16:32:18 |
| 合計ジャッジ時間 | 6,971 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
int main(){
mp::cpp_int mod=1000000007;
mp::cpp_int N,K;
cin>>N>>K;
vector<int> prime(0);
int upper=(int)sqrt(N)+1;
for(int i=2;i<=upper;++i){
if(N%i==0){
prime.push_back(0);
while(N%i==0){
N/=i;
++prime[prime.size()-1];
}
}
}
if(N>1){
prime.push_back(1);
}
mp::cpp_int ans=1;
for(int i:prime){
mp::cpp_int temp1=1,temp2=1;
for(int j=1;j<=i;++j){
temp1=(temp1*(j+K))%mod;
temp2=(temp2*j)%mod;
}
mp::cpp_int remain=mod-2;
mp::cpp_int d=1;
while(remain){
if(remain%2){
d=(d*temp2)%mod;
}
remain/=2;
temp2=(temp2*temp2)%mod;
}
temp1=(temp1*d)%mod;
ans=(ans*temp1)%mod;
}
cout<<((int)ans)<<endl;
}
ytft