結果

問題 No.690 E869120 and Constructing Array 4
ユーザー phsplsphspls
提出日時 2023-02-02 00:31:52
言語 Rust
(1.77.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 804 bytes
コンパイル時間 1,637 ms
コンパイル使用メモリ 145,036 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 09:51:45
合計ジャッジ時間 3,149 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 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 kstr = format!("{:b}", k).chars().map(|c| c as usize - '0' as usize).collect::<Vec<_>>();
    let n = kstr.len()+2;
    let mut lines = (0..n-1).map(|i| (i, i+1)).collect::<Vec<_>>();
    for size in 2..=n-2 {
        for start in 0.. {
            let end = start + size;
            if end+1 == n { break; }
            lines.push((start, end));
        }
    }
    for i in 0..kstr.len()-1 {
        if ((k >> i) & 1) == 1 {
            lines.push((i+1, n-1));
        }
    }
    println!("{} {}", n, lines.len());
    for &(l, r) in lines.iter() {
        println!("{} {}", l+1, r+1);
    }
}
0