結果
問題 |
No.2326 Factorial to the Power of Factorial to the...
|
ユーザー |
![]() |
提出日時 | 2023-05-28 14:25:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 560 bytes |
コンパイル時間 | 2,184 ms |
コンパイル使用メモリ | 192,256 KB |
最終ジャッジ日時 | 2025-02-13 11:26:18 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 WA * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; lint modpow(lint a, lint b, lint mod = 1e9+7) { lint ans = 1, now = a; for (int i = 0; i < 60; i++) { if (b&(1LL<<i)) ans *= now; now *= now; ans %= mod, now %= mod; } return ans; } int main() { lint n, p; cin >> n >> p; lint cnt = 0; lint power = 1; lint MOD = 1e9+7; for (lint i = 1; i <= n; i++) { lint x = i; power*=i; power%=MOD; while (x%p == 0) cnt++, x/=p; } lint num = modpow(power, power); cout << (num*cnt)%MOD << endl; }