結果
| 問題 |
No.2326 Factorial to the Power of Factorial to the...
|
| コンテスト | |
| ユーザー |
ozraru
|
| 提出日時 | 2023-05-28 15:58:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 986 bytes |
| コンパイル時間 | 1,811 ms |
| コンパイル使用メモリ | 192,392 KB |
| 最終ジャッジ日時 | 2025-02-13 14:51:02 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 WA * 4 TLE * 11 |
ソースコード
#include <bits/stdc++.h>
#include <numeric>
// #include <atcoder/modint>
using namespace std;
// using namespace atcoder;
// using mint = modint998244353;
#define i64 int_fast64_t
const i64 INF = INT64_MAX;
const i64 ERR = INT64_MIN;
const i64 MOD = 1000000007;
// 切り上げ
i64 ceil_devide(i64 x, i64 y) {
return (x + y - 1) / y;
}
// 切り捨て
i64 floor_devide(i64 x, i64 y) {
return x / y;
}
i64 sum_linear(i64 n) {
return n * (n+1) / 2;
}
int main()
{
i64 n,p;
cin >> n >> p;
i64 p_num = 0;
i64 res = 0;
for (size_t i = 1; true; i++)
{
i64 add = n / pow(p, i);
if (add < 1) {
break;
}
res += n / pow(p, i);
}
i64 kaizyou = 1;
for (size_t i = 1; i <= n; i++)
{
kaizyou *= i;
kaizyou %= MOD;
}
for (size_t i = 0; i < kaizyou; i++)
{
res *= kaizyou;
res %= MOD;
}
cout << res << endl;
return 0;
}
ozraru