結果

問題 No.1327 グラフの数え上げ
ユーザー trineutrontrineutron
提出日時 2020-12-24 00:38:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 957 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 2,332 ms
コンパイル使用メモリ 201,456 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 15:24:49
合計ジャッジ時間 5,008 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 142 ms
4,348 KB
testcase_02 AC 464 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 48 ms
4,348 KB
testcase_10 AC 957 ms
4,348 KB
testcase_11 AC 466 ms
4,348 KB
testcase_12 AC 467 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    constexpr int64_t mod = 1000000007;
    const int64_t fact[] = {1, 668123525, 724464507, 586445753};
    char s[12] = {};
    for (int i = 0; i < 11; i++) {
        s[i] = getchar();
    }
    if (isdigit(s[10])) {
        cout << 0 << endl;
        return 0;
    }
    int64_t n = 0;
    for (int i = 0; i < 10; i++) {
        if (not isdigit(s[i])) break;
        n *= 10;
        n += s[i] - '0';
    }
    n--;
    if (n > mod) {
        cout << 0 << endl;
        return 0;
    }
    int64_t ans = fact[n / 300000000];
    for (int i = n / 300000000 * 300000000 + 1; i <= n; i++) {
        ans *= mod - i;
        ans %= mod;
    }
    cout << ans << endl;
}
0