結果

問題 No.523 LED
ユーザー @abcde@abcde
提出日時 2019-05-21 00:08:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 875 bytes
コンパイル時間 1,595 ms
コンパイル使用メモリ 166,764 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 10:16:04
合計ジャッジ時間 3,856 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 4 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 161 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 33 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 162 ms
4,348 KB
testcase_19 AC 59 ms
4,348 KB
testcase_20 AC 52 ms
4,348 KB
testcase_21 AC 121 ms
4,348 KB
testcase_22 AC 136 ms
4,348 KB
testcase_23 AC 136 ms
4,348 KB
testcase_24 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 1e9 + 7;

int main() {
    
    // 1. 入力情報取得.
    LL N;
    cin >> N;
    
    // 2. LED の 操作手順 を カウント.
    // LED 1個につき, 操作手順(緑 -> 黄, 黄 -> 赤)が, 2つあるので, 
    // LED k個で, 操作手順は, 2 × k 通りから選択することになる.
    // 但し, 各LED ごとに, 操作手順の順序は決まっているので,
    // (2 × k)! ÷ (2 の k乗) 通りになると推測.
    LL ans = 1;
    for(int i = 1; i <= N * 2; i++){
        ans *= i;
        ans %= MOD;
        // 2 で割る -> 500000004 を 乗ずる形に修正.
        if(i % 2 == 0) ans *= 500000004, ans %= MOD;;
    }

    // 3. 後処理.
    // ex.
    // N = 10000000 ならば, 260624814 で, OK?.
    cout << ans << endl;
    return 0;
    
}
0