結果

問題 No.264 じゃんけん
ユーザー triggerwaffletriggerwaffle
提出日時 2020-09-02 02:23:05
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 733 bytes
コンパイル時間 13,822 ms
コンパイル使用メモリ 387,820 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 04:58:24
合計ジャッジ時間 14,731 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `ans` is assigned to, but never used
  --> src/main.rs:19:13
   |
19 |     let mut ans = String::new();
   |             ^^^
   |
   = note: consider using `_ans` instead
   = note: `#[warn(unused_variables)]` on by default

warning: value assigned to `ans` is never read
  --> src/main.rs:20:19
   |
20 |     if a-b == 0 { ans = String::from("Drew"); }
   |                   ^^^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

warning: value assigned to `ans` is never read
  --> src/main.rs:21:20
   |
21 |     if a-b == -2 { ans = String::from("Lose"); }
   |                    ^^^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `ans` is never read
  --> src/main.rs:22:19
   |
22 |     if a-b == 1 { ans = String::from("Lose"); }
   |                   ^^^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `ans` is never read
  --> src/main.rs:23:11
   |
23 |     else {ans = String::from("Won");}
   |           ^^^
   |
   = help: maybe it is overwritten before being read?

ソースコード

diff #

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read(); // (*)
    let b: i64 = read();
    let mut ans = String::new();
    if a-b == 0 { ans = String::from("Drew"); }
    if a-b == -2 { ans = String::from("Lose"); }
    if a-b == 1 { ans = String::from("Lose"); }
    else {ans = String::from("Won");}
    let ans = a * (a+1)/2;
    println!("{}", ans);
}
0