結果

問題 No.690 E869120 and Constructing Array 4
ユーザー phsplsphspls
提出日時 2023-01-19 00:41:41
言語 Rust
(1.77.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 677 bytes
コンパイル時間 3,317 ms
コンパイル使用メモリ 144,156 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 17:48:21
合計ジャッジ時間 5,020 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

fn main() {
    let mut k = String::new();
    std::io::stdin().read_line(&mut k).ok();
    let k: usize = k.trim().parse().unwrap();

    if k == 0 {
        println!("2 0");
        return;
    }
    let n = format!("{:b}", k).len() + 2;
    let mut lines = vec![(n-1, n)];
    for width in 1..n-1 {
        for start in 1.. {
            let end = start + width;
            if end > n-1 { break; }
            lines.push((start, end));
        }
    }
    for i in 2..n-1 {
        if ((k >> (i-2)) & 1) == 1 {
            lines.push((i, n));
        }
    }
    println!("{} {}", n, lines.len());
    for &(l, r) in lines.iter() {
        println!("{} {}", l, r);
    }
}
0