結果
問題 | No.1659 Product of Divisors |
ユーザー |
|
提出日時 | 2023-02-23 13:14:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 1,255 bytes |
コンパイル時間 | 897 ms |
コンパイル使用メモリ | 78,252 KB |
最終ジャッジ日時 | 2025-02-10 20:02:05 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 |
ソースコード
#include<iostream> #include<vector> #include<queue> using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i<n;i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} const ll MOD=1e9+7; ll f(ll n,ll k,vector<ll>&inv){ if(k<0||n<k)return 0; ll re=1; rep(i,k){ re*=(n-i)%MOD; re%=MOD; re*=inv[i+1]; re%=MOD; } return re; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll N,K; cin>>N>>K; vector<int>V; ll b=2; while(b*b<=N){ int cnt=0; while(N%b==0){ N/=b; cnt++; } if(cnt>0)V.push_back(cnt); b++; } if(N>1)V.push_back(1); vector<ll>inv(60); inv[1]=1; for (int i=2;i<60;i++){ inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD; } ll ans=1; for(auto x:V){ ll d=0; rep(i,x+1){ d+=f(K+i-1,i,inv); d%=MOD; } ans*=d; ans%=MOD; } cout<<ans<<"\n"; }