結果
| 問題 |
No.2326 Factorial to the Power of Factorial to the...
|
| コンテスト | |
| ユーザー |
keisuke6
|
| 提出日時 | 2023-05-28 13:41:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 526 bytes |
| コンパイル時間 | 1,902 ms |
| コンパイル使用メモリ | 192,536 KB |
| 最終ジャッジ日時 | 2025-02-13 10:08:51 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
int int_pow(int a, int x, int mod){
if(x == 0) return 1;
if(x%2 == 0){
int t = int_pow(a,x/2,mod);
return t*t%mod;
}
else return (int_pow(a,x-1,mod)*a)%mod;
}
signed main(){
int N,P;
cin>>N>>P;
int mod = 1e9+7;
int ans = 0;
int a = 1, b = 1;
for(int i=1;i<=N;i++){
a *= i;
a %= mod;
b *= i;
b %= mod-1;
}
int t = int_pow(a,b,mod);
int pp = P;
while(N >= P){
ans += N/P;
P *= pp;
}
cout<<(ans*t)%mod<<endl;
}
keisuke6