結果

問題 No.1327 グラフの数え上げ
ユーザー trineutron
提出日時 2020-12-24 00:38:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,011 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 1,717 ms
コンパイル使用メモリ 191,856 KB
最終ジャッジ日時 2025-01-17 06:32:00
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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