結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー CleyLCleyL
提出日時 2023-07-14 14:51:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 695 ms
コンパイル使用メモリ 68,540 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-14 04:22:13
合計ジャッジ時間 2,238 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,368 KB
testcase_12 AC 1 ms
4,368 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,372 KB
testcase_15 WA -
testcase_16 AC 1 ms
4,372 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
4,372 KB
testcase_20 AC 1 ms
4,368 KB
testcase_21 AC 1 ms
4,372 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(int i = 1; n >= i; i++){
    nw = (nw*i)%MOD;
  }
  long long r = uPow(nw,nw,MOD);
  long long x = 0;
  for(int i = p; n >= i; i+=p){
    int nwi = i;
    while(nwi%p == 0){
      nwi/=p;
      x++;
    }
  }
  cout << (x*r)%MOD << endl;
}
0