結果
| 問題 |
No.2365 Present of good number
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-30 23:48:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,678 bytes |
| コンパイル時間 | 4,078 ms |
| コンパイル使用メモリ | 260,996 KB |
| 最終ジャッジ日時 | 2025-02-15 04:46:38 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 39 |
ソースコード
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll,ll>;
#define pb push_back
#define int long long
#define double long double
#define INF (ll) 3e18
// Ctrl + Shift + B コンパイル
// Ctrl + C 中断
// ./m 実行
// 行列累乗のライブラリ
// https://atcoder.jp/contests/abc204/submissions/23280760
template<typename T>
struct Matrix {
int h, w;
vector<vector<T>> d;
Matrix() {}
Matrix(int h, int w, T val=0): h(h), w(w), d(h, vector<T>(w,val)) {}
Matrix& unit() {
assert(h == w);
rep(i,h) d[i][i] = 1;
return *this;
}
const vector<T>& operator[](int i) const { return d[i];}
vector<T>& operator[](int i) { return d[i];}
Matrix operator*(const Matrix& a) const {
assert(w == a.h);
Matrix r(h, a.w);
rep(i,h)rep(k,w)rep(j,a.w) {
r[i][j] += d[i][k]*a[k][j];
}
return r;
}
Matrix pow(ll t) const {
assert(h == w);
if (!t) return Matrix(h,h).unit();
if (t == 1) return *this;
Matrix r = pow(t>>1);
r = r*r;
if (t&1) r = r*(*this);
return r;
}
};
signed main(){
using mint = modint1000000007;
int n, k;
cin >> n >> k;
vvl soinsu(100010); // 素因数分解
for(int i = 2; i <= 100000; i++){
int now = i;
for(auto x : soinsu[i]) now /= x;
if (now != 1){
for(int j = i; j <= 100000; j += i) soinsu[j].push_back(now);
}
}
vector<mint> ans(100010);
for(int i = 2; i <= 100010; i++){
while(n % i == 0) {
ans[i]++;
n /= i;
}
}
// rep(i, min(k, 100LL)){
// vector<mint> next(100010);
// rep(j, 100010){
// for(auto x : soinsu[j]){
// next[x] += ans[j-1];
// }
// }
// ans = next;
// }
// k -= min(k, 100LL);
if (k == 0) {
mint res = 1;
rep(i,100010){
if (ans[i].val()) res *= (mint(i)).pow(ans[i].val());
}
cout << res.val() << endl;
} else {
Matrix<mint> d(110,110);
rep(i,110){
for(auto x : soinsu[i]) d[x][i-1]++;
}
Matrix<mint> x(110,1);
// rep(i,110) x[i][0] = ans[i];
rep(i, 110){
rep(j,110){
// if (d[i][j].val()) cout << i << " " << j << " " << d[i][j].val() << endl;
}
}
rep(i,110){
// if (x[i][0].val()) cout << i << " " << x[i][0].val() << endl;
}
x = d.pow(k)*x;
mint res = 1;
rep(i,110){
if (x[i][0].val()) res *= (mint(i)).pow(x[i][0].val());
// if (x[i][0].val()) cout << i << " " << x[i][0].val() << endl;
}
cout << res.val() << endl;
}
}