結果

問題 No.2365 Present of good number
ユーザー random contestantrandom contestant
提出日時 2023-06-30 22:47:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,492 bytes
コンパイル時間 4,621 ms
コンパイル使用メモリ 270,812 KB
実行使用メモリ 17,508 KB
最終ジャッジ日時 2023-09-21 16:59:21
合計ジャッジ時間 13,051 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
17,228 KB
testcase_01 AC 59 ms
17,164 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 53 ms
17,220 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 56 ms
17,156 KB
testcase_18 AC 64 ms
17,216 KB
testcase_19 WA -
testcase_20 AC 72 ms
17,212 KB
testcase_21 AC 62 ms
17,292 KB
testcase_22 WA -
testcase_23 AC 80 ms
17,360 KB
testcase_24 AC 76 ms
17,256 KB
testcase_25 WA -
testcase_26 AC 52 ms
17,164 KB
testcase_27 AC 51 ms
17,168 KB
testcase_28 AC 55 ms
17,496 KB
testcase_29 AC 57 ms
17,504 KB
testcase_30 AC 65 ms
17,240 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 51 ms
17,324 KB
testcase_37 AC 53 ms
17,500 KB
testcase_38 AC 52 ms
17,300 KB
testcase_39 AC 55 ms
17,308 KB
testcase_40 AC 53 ms
17,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #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);
    }
  }
  vvl soinsu_inv(100010);
  rep(i,100000){
    for(auto x : soinsu[i]) soinsu_inv[x].push_back(i-1);
  }
  vector<mint> ans(100010);
  for(int i = 2; i <= 100010; i++){
    while(n % i == 0) {
      ans[i]++;
      n /= i;
    }
  }
  rep(i, min(k, 10LL)){
    vector<mint> next(100010);
    rep(j, 100010){
      for(auto x : soinsu_inv[j]){
        next[j] += ans[x];
      }
    }
    ans = next;
    if (k & (1LL << i)){
      
    }
  }
  k -= min(k, 10LL);
  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];
    x = d.pow(k) * x;
    mint res = 1;
    rep(i,110){
      if (x[i][0].val()) res *= (mint(i)).pow(x[i][0].val());
    }
    cout << res.val() << endl;
  }
}
0