結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー CleyLCleyL
提出日時 2023-07-14 17:08:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 586 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 69,260 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 06:54:30
合計ジャッジ時間 1,832 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,352 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,348 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,352 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
4,352 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0