結果

問題 No.2881 Mod 2^N
ユーザー ArcAki
提出日時 2024-09-10 11:50:13
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 12,493 ms
コンパイル使用メモリ 401,248 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-10 11:50:30
合計ジャッジ時間 14,632 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::{input};

fn main() {
    input!{
        n: usize, x: i64, y: i64,
    }
    if x==y{
        println!("0");
        return;
    } else if y&1==0{
        println!("-1");
        return;
    }
    let mut query = vec![n.to_string()];
    let mut x = true;
    let mut pre = 0;
    for i in (0..n).rev(){
        if y & 1<<i > 0{
            if x{
                x = false;
                pre = i;
            } else {
                query.push((pre-i).to_string());
                pre = i;
            }
        }
    }
    println!("{}\n{}", query.len(), query.join(" "));

}
0