結果

問題 No.523 LED
ユーザー tonyu0tonyu0
提出日時 2020-04-05 14:27:16
言語 Rust
(1.72.1)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 693 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 142,288 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-16 06:36:57
合計ジャッジ時間 2,294 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 142 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 27 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 138 ms
4,376 KB
testcase_19 AC 50 ms
4,380 KB
testcase_20 AC 44 ms
4,376 KB
testcase_21 AC 103 ms
4,504 KB
testcase_22 AC 116 ms
4,376 KB
testcase_23 AC 115 ms
4,376 KB
testcase_24 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;
const MOD: u64 = 1_000_000_007;

fn inv(mut x: u64) -> u64 {
    let mut res = 1;
    let mut e = MOD - 2;
    while e > 0 {
        if e & 1 == 1 {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        e >>= 1;
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: u64 = itr.next().unwrap().parse().unwrap();

    let mut ans = 1;
    let mut two = 1;
    for i in 1..(n << 1) + 1 {
        ans = ans * i % MOD;
    }
    for _ in 0..n {
        two = two * 2 % MOD;
    }
    ans = ans * inv(two) % MOD;
    println!("{}", ans);
}
0