結果
| 問題 |
No.2326 Factorial to the Power of Factorial to the...
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-28 16:02:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,388 bytes |
| コンパイル時間 | 2,102 ms |
| コンパイル使用メモリ | 166,140 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 10:36:48 |
| 合計ジャッジ時間 | 2,278 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 9 |
ソースコード
#include <bits/stdc++.h>
// #include <atcoder/dsu>
// #include <atcoder/modint>
using namespace std;
// using namespace atcoder;
#define SZ(x) (int)(x).size()
#define dout(x) printf("%.10f\n", (double)(x))
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
typedef pair<int, int> P;
typedef pair<long, long> Pl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long>> vvl;
long gcd(long a, long b)
{
if (b == 0)
{
return a;
}
else
{
return gcd(b, a % b);
}
}
/* lcm (a, b) : 2整数版
入力:整数 a, b
出力:aとbの最小公倍数
*/
long lcm(long a, long b)
{
long d = gcd(a, b);
return a / d * b;
}
int main()
{
long N, P, waru = 1000000007;
cin >> N >> P;
long ans = 1, zn = 0, sinans = 1, tasu;
for (long i = N; i > 0; i--)
{
sinans *= i;
sinans %= waru;
ans = i;
while (ans % P == 0)
{
ans /= P;
zn++;
zn %= waru;
}
}
ans = 1;
tasu = sinans;
for (long i = 0; ((long)1 << i) <= sinans; i++)
{
if (((long)1 << i) & sinans)
{
ans *= tasu;
ans %= waru;
}
tasu *= tasu;
tasu %= waru;
}
long fans = zn * ans;
fans %= waru;
cout << fans << endl;
return 0;
}