結果

問題 No.903 太郎の確率
ユーザー shinozakishinozaki
提出日時 2019-11-05 19:48:35
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 5,874 ms
コンパイル使用メモリ 126,100 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 02:28:28
合計ジャッジ時間 1,929 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,356 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::convert::TryFrom`
 --> Main.rs:2:5
  |
2 | use std::convert::TryFrom;
  |     ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unnecessary parentheses around `if` condition
  --> Main.rs:16:11
   |
16 |         if(n < 1 || n > 100) { continue; }
   |           ^                ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
16 -         if(n < 1 || n > 100) { continue; }
16 +         if n < 1 || n > 100 { continue; }
   |

warning: 2 warnings emitted

ソースコード

diff #

use std::io;
use std::convert::TryFrom;

fn main() {
    let stdin = io::stdin();
    let mut n: String = String::new();
    stdin.read_line(&mut n).ok();
    let f:f32;
    loop
    {
        let n:i8 = match n.trim().parse() 
        {
            Ok(num) => num,
            Err(_) => continue,
        };
        if(n < 1 || n > 100) { continue; }
        f = 1.0/(n as f32);
        break;
    }
    print!("{:.6}",f);

}
0