結果

問題 No.1327 グラフの数え上げ
コンテスト
ユーザー trineutron
提出日時 2020-12-24 00:38:14
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 835 ms / 2,000 ms
コード長 728 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,091 ms
コンパイル使用メモリ 211,700 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-16 05:16:28
合計ジャッジ時間 4,730 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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