結果
| 問題 |
No.2326 Factorial to the Power of Factorial to the...
|
| コンテスト | |
| ユーザー |
bluebery1001
|
| 提出日時 | 2023-05-28 14:31:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,327 bytes |
| コンパイル時間 | 2,016 ms |
| コンパイル使用メモリ | 167,832 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 01:45:27 |
| 合計ジャッジ時間 | 2,296 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 9 |
ソースコード
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;
rep(i,1,n+1){
ll x = i;
while (x%p==0)
{
cnt++;
x/=p;
}
}
ll n_f=1;
rep(i,1,n+1){
(n_f*=i)%=MOD;
}
cout<<(modpow(n_f,n_f)*cnt)%MOD<<endl;
}
bluebery1001