結果
| 問題 |
No.2326 Factorial to the Power of Factorial to the...
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2023-07-14 17:08:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 586 bytes |
| コンパイル時間 | 524 ms |
| コンパイル使用メモリ | 66,932 KB |
| 最終ジャッジ日時 | 2025-02-15 10:21:49 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 9 |
ソースコード
#include <iostream>
using namespace std;
const long long MOD = 1000000007;
template <typename T>
T uPow(T z,T n, T mod){
T ans = 1;
while(n != 0){
if(n%2){
ans*=z;
if(mod)ans%=mod;
}
n >>= 1;
z*=z;
if(mod)z%=mod;
}
return ans;
}
int main(){
long long n,p;cin>>n>>p;
long long nw = 1;
for(long long i = 1; n >= i; i++){
nw = (nw*i)%MOD;
}
long long r = uPow(nw,nw,MOD);
long long x = 0;
for(long long i = p; n >= i; i+=p){
int nwi = i;
while(nwi%p == 0){
nwi/=p;
x++;
}
}
cout << (x*r)%MOD << endl;
}