結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー ozraruozraru
提出日時 2023-05-28 15:58:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 986 bytes
コンパイル時間 1,929 ms
コンパイル使用メモリ 197,896 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 13:31:27
合計ジャッジ時間 18,746 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0