結果

問題 No.1298 OR XOR
ユーザー StrorkisStrorkis
提出日時 2020-11-27 21:32:26
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,353 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 142,424 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-01 04:55:01
合計ジャッジ時間 1,734 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 1 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,380 KB
testcase_13 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::prelude::*;

fn input<R: BufRead>(stdin: &mut R) -> String {
    let mut input = String::new();
    stdin.read_line(&mut input).ok();
    input
}

macro_rules! read {
    ($stdin:expr, [$t:tt; $n:expr]) => {
        (0..$n).map(|_| read!($stdin, $t)).collect::<Vec<_>>()
    };
    ($stdin:expr, [$t:tt]) => {
        input($stdin).split_whitespace().map(|s| parse!(s, $t)).collect::<Vec<_>>()    
    };
    ($stdin:expr, ($($t:tt),*)) => {{
        let input = input($stdin);
        let mut iter = input.split_whitespace();    
        ($(parse!(iter.next().unwrap(), $t)),*)    
    }};
    ($stdin:expr, $t:tt) => {
        parse!(input($stdin).trim(), $t)
    };
}

macro_rules! parse {
    ($s:expr, Chars) => ($s.chars().collect::<Vec<_>>());
    ($s:expr, Usize1) => (parse!($s, usize) - 1);
    ($s:expr, $t:ty) => ($s.parse::<$t>().unwrap());
}

fn solve<R: BufRead, W: Write>(stdin: &mut R, writer: &mut W) {
    let n = read!(stdin, u32);

    let x = 1 << 31 - n.leading_zeros();
    if n == x {
        writeln!(writer, "-1 -1 -1").ok();
    } else {
        writeln!(writer, "{} {} {}", n, x, n - x).ok();
    }
}

fn main() {
    let stdin = std::io::stdin();
    let stdin = &mut stdin.lock();

    let stdout = std::io::stdout();
    let writer = &mut std::io::BufWriter::new(stdout.lock());

    solve(stdin, writer);
}
0