結果

問題 No.1232 2^x = x
ユーザー tzyvrntzyvrn
提出日時 2020-09-19 14:03:42
言語 Rust
(1.77.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 918 bytes
コンパイル時間 1,025 ms
コンパイル使用メモリ 152,756 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 18:31:41
合計ジャッジ時間 1,611 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: use of deprecated associated function `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> Main.rs:8:23
   |
8  |             let s = s.trim_right();
   |                       ^^^^^^^^^^
...
29 |     let n = getl!(usize);
   |             ------------ in this macro invocation
   |
   = note: `#[warn(deprecated)]` on by default
   = note: this warning originates in the macro `getl` (in Nightly builds, run with -Z macro-backtrace for more info)
help: replace the use of the deprecated associated function
   |
8  |             let s = s.trim_end();
   |                       ~~~~~~~~

warning: use of deprecated associated function `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> Main.rs:8:23
   |
8  |             let s = s.trim_right();
   |                       ^^^^^^^^^^
...
32 |         p.push(getl!(i64));
   |                ---------- in this macro invocation
   |
   = note: this warning originates in the macro `getl` (in Nightly builds, run with -Z macro-backtrace for more info)
help: replace the use of the deprecated associated function
   |
8  |             let s = s.trim_end();
   |                       ~~~~~~~~

warning: 2 warnings emitted

ソースコード

diff #

//{{{
#[allow(unused_macros)]
macro_rules! getl {
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let s = s.trim_right();
            let mut ws = s.split_whitespace();
            ($(ws.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! getl_vec {
    ( $t:ty ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right();
        s.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect::<Vec<$t>>()
    }};
}
//}}}

fn main() {
    let n = getl!(usize);
    let mut p = vec![];
    for _ in 0..n {
        p.push(getl!(i64));
    }

    for p in p {
        if p == 2 {
            println!("2");
        } else {
            println!("{}", (p - 1) * (p - 1));
        }
    }
}
0