結果

問題 No.1259 スイッチ
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-04-13 15:13:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,097 bytes
コンパイル時間 3,082 ms
コンパイル使用メモリ 199,356 KB
実行使用メモリ 11,848 KB
最終ジャッジ日時 2024-04-13 15:13:22
合計ジャッジ時間 6,253 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
11,716 KB
testcase_01 AC 15 ms
11,592 KB
testcase_02 AC 15 ms
11,716 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 15 ms
11,840 KB
testcase_06 AC 15 ms
11,588 KB
testcase_07 AC 15 ms
11,592 KB
testcase_08 WA -
testcase_09 AC 15 ms
11,716 KB
testcase_10 AC 22 ms
11,712 KB
testcase_11 AC 25 ms
11,584 KB
testcase_12 AC 21 ms
11,588 KB
testcase_13 AC 18 ms
11,720 KB
testcase_14 AC 20 ms
11,592 KB
testcase_15 AC 18 ms
11,712 KB
testcase_16 AC 23 ms
11,716 KB
testcase_17 AC 19 ms
11,716 KB
testcase_18 AC 24 ms
11,844 KB
testcase_19 AC 23 ms
11,588 KB
testcase_20 AC 21 ms
11,588 KB
testcase_21 AC 25 ms
11,716 KB
testcase_22 AC 17 ms
11,848 KB
testcase_23 AC 24 ms
11,716 KB
testcase_24 AC 22 ms
11,716 KB
testcase_25 AC 21 ms
11,712 KB
testcase_26 AC 25 ms
11,712 KB
testcase_27 AC 23 ms
11,588 KB
testcase_28 AC 21 ms
11,716 KB
testcase_29 AC 23 ms
11,844 KB
testcase_30 AC 19 ms
11,840 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 20 ms
11,844 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 20 ms
11,844 KB
testcase_49 WA -
testcase_50 AC 21 ms
11,720 KB
testcase_51 AC 18 ms
11,844 KB
testcase_52 AC 24 ms
11,716 KB
testcase_53 AC 19 ms
11,712 KB
testcase_54 AC 24 ms
11,716 KB
testcase_55 AC 18 ms
11,716 KB
testcase_56 AC 19 ms
11,840 KB
testcase_57 AC 24 ms
11,716 KB
testcase_58 AC 20 ms
11,716 KB
testcase_59 AC 28 ms
11,720 KB
testcase_60 AC 26 ms
11,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/modint>
using namespace std;
using mint = atcoder::modint1000000007;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

mint fac[1 << 20], inv[1 << 20];
void init() {
    fac[0] = 1;
    for (int i = 1; i < (1 << 20); i++) {
        fac[i] = fac[i - 1] * i;
    }
    inv[(1 << 20) - 1] = fac[(1 << 20) - 1].inv();
    for (int i = (1 << 20) - 2; i >= 0; i--) {
        inv[i] = inv[i + 1] * (i + 1);
    }
}
mint binom(int n, int k) {
    if (n < k || k < 0 || n < 0) {
        return 0;
    }
    return fac[n] * inv[k] * inv[n - k];
}
mint perm(int n, int k) {
    if (n < k || k < 0 || n < 0) {
        return 0;
    }
    return fac[n] * inv[n - k];
}
int main() {
    fast_io();
    init();
    int n, k;
    long long m;
    cin >> n >> m >> k;
    mint ans = 0;
    for (int i = 1; i <= n; i++) {
        if (m % i == 0) {
            ans += perm(n - 1, i - 1) * mint(n).pow(n - i);
        }
    }
    if (m != 1) {
        ans = mint(n).pow(n) - ans;
        ans /= (n - 1);
    }
    cout << ans.val() << endl;
}
0