結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー bluebery1001bluebery1001
提出日時 2023-05-28 14:24:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,289 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 165,672 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-27 09:41:11
合計ジャッジ時間 2,606 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

using namespace std;
#include<bits/stdc++.h>
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(15);_main(); return 0;}
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef long double ld;
template<class ll> inline bool chmax(ll& a, ll b) { if (a < b) { a = b; return 1; } return 0; }
template<class ll> inline bool chmin(ll& a, ll b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i, star,fini) for (int i = star; i < fini; i++)
#define ALL(x) std::begin(x), std::end(x)
#define INF ((1LL<<62)-(1LL<<31))
#define bit(x,i)(((x)>>(i))&1)
long double distance(long double xi,long double yi,long double xj,long double yj){return sqrt(1.0*((xi-xj)*(xi-xj))+1.0*((yi-yj)*(yi-yj)));}
ll MOD = 1000000007;
long long modpow(long long a, long long n) {
    ll mod = MOD;
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
void _main(){
    ll n,p;cin >> n >> p;
    ll cnt = 0;
    ll x = n;
    while (x>0)
    {
        cnt += x/p;
        cnt%=MOD;
        x/=p;
    }
    ll n_f=1;
    rep(i,1,n+1){
        (n_f*=i)%=MOD;
    }
    cout<<(modpow(n_f,n_f)*cnt)%MOD<<endl; 
}
0