結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー umezoumezo
提出日時 2023-05-28 14:27:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 826 bytes
コンパイル時間 2,149 ms
コンパイル使用メモリ 199,396 KB
実行使用メモリ 8,388 KB
最終ジャッジ日時 2023-08-27 09:47:34
合計ジャッジ時間 3,318 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

const int MAX=200200;
const int MOD=1e9+7;
ll fac[MAX],finv[MAX],inv[MAX];

void init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll nCr(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll modpow(ll x,ll n){
  ll ans=1;
  while(n){
    if(n&1) ans=ans*x%MOD;
    x=x*x%MOD;
    n/=2;
  }
  return ans;
}
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  init();
  
  ll n,p;
  cin>>n>>p;  
  cout<<n/p*modpow(fac[n],fac[n])%MOD<<endl;

  return 0;
}
0