結果
| 問題 |
No.2326 Factorial to the Power of Factorial to the...
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2024-12-06 13:18:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 559 bytes |
| コンパイル時間 | 2,023 ms |
| コンパイル使用メモリ | 194,504 KB |
| 最終ジャッジ日時 | 2025-02-26 11:13:38 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
#include <atcoder/modint>
using mint = atcoder::modint1000000007;
const int MOD = 1e9 + 7;
int main() {
fast_io();
int n, p;
cin >> n >> p;
int cnt = 0;
{
int pp = p;
while (n >= pp) {
cnt += n / pp;
if (pp > INT_MAX / p) break;
pp *= p;
}
}
mint ans = 1;
long long fact = 1;
for (int i = 2; i <= n; i++) {
ans *= i;
fact *= i;
fact %= (MOD - 1);
}
ans = ans.pow(fact) * cnt;
cout << ans.val() << endl;
}
eve__fuyuki