結果
| 問題 | No.2365 Present of good number |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-30 23:49:22 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,645 bytes |
| 記録 | |
| コンパイル時間 | 3,278 ms |
| コンパイル使用メモリ | 285,428 KB |
| 実行使用メモリ | 12,036 KB |
| 最終ジャッジ日時 | 2026-07-01 13:49:03 |
| 合計ジャッジ時間 | 10,901 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 WA * 22 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/vector:67,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/functional:66,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:55,
from main.cpp:2:
In function '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = atcoder::static_modint<1000000007>*; _ForwardIterator = atcoder::static_modint<1000000007>*]',
inlined from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _Sentinel, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = atcoder::static_modint<1000000007>*; _Sentinel = atcoder::static_modint<1000000007>*; _ForwardIterator = atcoder::static_modint<1000000007>*; _Tp = atcoder::static_modint<1000000007>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_uninitialized.h:637:37,
inlined from 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = atcoder::static_modint<1000000007>; _Alloc = std::allocator<atcoder::static_modint<1000000007> >]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/vector.tcc:257:35,
inlined from 'int main()' at main.cpp:80:11:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_uninitialized.h:273:31: warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' writing between 1 and 400040 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
273 | __builtin_memcpy(std::__niter_base(__result),
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
274 | std::__niter_base(__first),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
275 | __n * sizeof(_ValT));
|
ソースコード
// #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;
}
}