結果
| 問題 |
No.2326 Factorial to the Power of Factorial to the...
|
| コンテスト | |
| ユーザー |
rurun
|
| 提出日時 | 2023-05-28 14:42:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 575 bytes |
| コンパイル時間 | 1,774 ms |
| コンパイル使用メモリ | 192,960 KB |
| 最終ジャッジ日時 | 2025-02-13 11:56:38 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
lint MOD = 1000000007;
lint modpow(lint a, lint b, lint mod) {
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;
for (lint i = 1; i <= n; i++) {
lint x = i;
power*=i;
power%=MOD;
while (x%p == 0) cnt++, x/=p;
}
cnt %= MOD;
lint num = modpow(power, power, MOD);
cout << (num*cnt)%MOD << endl;
}
rurun