結果

問題 No.8 N言っちゃダメゲーム
ユーザー nobuta05nobuta05
提出日時 2016-11-12 20:41:55
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 811 bytes
コンパイル時間 1,167 ms
コンパイル使用メモリ 149,988 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-17 03:56:29
合計ジャッジ時間 2,307 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `i`
  --> Main.rs:25:7
   |
25 |   for i in 0..n {
   |       ^ help: if this is intentional, prefix it with an underscore: `_i`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

ソースコード

diff #

fn getline() -> String
{
  let mut inp: String = String::new();
  match std::io::stdin().read_line(&mut inp) {
    Ok(_) => inp.trim().to_string(),
    Err(error) => format!("{}", error),
  }
}

fn judge(n: &i32, k: &i32) -> bool
{
  if (n-1) % (k+1) == 0 {
    false
  }
  else {
    true
  }
}

fn main()
{
  let mut inp: String = getline();
  let n: i32 = inp.parse().unwrap();

  for i in 0..n {
    inp = getline();
    let mut args: Vec<i32> = Vec::new();
    let tmp: Vec<_> = inp.split(" ").collect();

    for x in tmp {
      match x.parse::<i32>() {
        Ok(var) => args.push(var),
        Err(log) => println!("{}", log),
      }
    }
    if args.len() == 2 {
     if judge(&args[0], &args[1]) == true {
        println!("Win");
      }
      else {
        println!("Lose");
      }
    }
  }
}
0