Submission #1992582


Source Code Expand

use std::io;
use std::env;

fn main(){
    let argv: Vec<String> = env::args().collect();
    let mut deg:i32;// = argv[1].parse().unwrap();
    let mut dis:i32;// = argv[2].parse().unwrap();
    //println!("len : {}", argv.len());
    if argv.len() == 3 {
        deg = argv[1].parse().unwrap();
        dis = argv[2].parse().unwrap();
    } else {
        // string に一行取得。
        let mut string:String = String::new();
        io::stdin().read_line(&mut string).ok();

        // スペースで分割
        let args:Vec<_> = string.trim().split(' ').collect();

        // args[] に文字列として引数が入っている。

        deg = args[0].parse().unwrap();
        dis = args[1].parse().unwrap();
    }


    //println!("風向き : {:?}", deg);
    // 風向
    let deg:f32 = (deg as f32 + 112.5) / 225.0;
    //println!("deg : {}", deg);
    let deg2:i32 = deg as i32;
    let mut deg = String::new();
    match deg2 {
        0  => deg = "N".to_string(),

        1  => deg = "NNE".to_string(),
        2  => deg = "NE".to_string(),
        3  => deg = "ENE".to_string(),

        4  => deg = "E".to_string(),

        5  => deg = "ESE".to_string(),
        6  => deg = "SE".to_string(),
        7  => deg = "SSE".to_string(),

        8  => deg = "S".to_string(),

        9  => deg = "SSW".to_string(),
        10 => deg = "SW".to_string(),
        11 => deg = "WSW".to_string(),

        12 => deg = "W".to_string(),

        13 => deg = "WNW".to_string(),
        14 => deg = "NW".to_string(),
        15 => deg = "NNW".to_string(),

        _  => deg = "N".to_string(),
    }

    // 風速
    //let mut dis:f64 = (dis as f64) / 60.0;
    //let tmp = dis * 100.0 + 5.0;
    //println!("dis : {}", tmp);
    //dis = (tmp - tmp % 10.0) / 100.0;
    //println!("dis : {}", dis);
    let mut wlevel = 0;
    let tmp = (dis as f64) / 60.0;
    //println!("風速 : {}", tmp);

    if dis <= 14 {
        wlevel = 0;
    } else if dis <= 92 {
        wlevel = 1;
    } else if dis <= 200 {
        wlevel = 2;
    } else if dis <= 326 {
        wlevel = 3;
    } else if dis <= 476 {
        wlevel = 4;
    } else if dis <= 644 {
        wlevel = 5;
    } else if dis <= 830 {
        wlevel = 6;
    } else if dis <= 1028 {
        wlevel = 7;
    } else if dis <= 1244 {
        wlevel = 8;
    } else if dis <= 1466 {
        wlevel = 9;
    } else if dis <= 1706 {
        wlevel = 10;
    } else if dis <= 1958 {
        wlevel = 11;
    } else {
        wlevel = 12;
    }


    if wlevel == 0 {
        println!("C 0");
    } else {
        println!("{} {}", deg, wlevel);
    }
}


//1029 / 60 = 17.15

Submission Info

Submission Time
Task C - 風力観測
User haaatchi
Language Rust (1.15.1)
Score 100
Code Size 2754 Byte
Status AC
Exec Time 2 ms
Memory 4352 KB

Compile Error

warning: value assigned to `deg` is never read, #[warn(unused_assignments)] on by default
  --> ./Main.rs:32:9
   |
32 |     let mut deg = String::new();
   |         ^^^^^^^

warning: value assigned to `wlevel` is never read, #[warn(unused_assignments)] on by default
  --> ./Main.rs:67:9
   |
67 |     let mut wlevel = 0;
   |         ^^^^^^^^^^

warning: unused variable: `tmp`, #[warn(unused_variables)] on by default
  --> ./Main.rs:68:9
   |
68 |     let tmp = (dis as f64) / 60.0;
   |         ^^^

warning: variable does not need to be mutable, #[warn(unused_mut)] on by default
 --> ./Main.rs:6:9
  |
6 |     let mut deg:i32;// = argv[1].parse().unwrap();
  |         ^^^^^^^

warning: variable does not need to be mutable, #[warn(unused_mut)] on by default
 --> ./Main.rs:7:9
  |
7 |     let mut dis:i32;// = argv[2].parse().unwrap();
  |         ^^^^^^^

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 66
Set Name Test Cases
all 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 00_sample_06.txt, 00_sample_07.txt, 00_sample_08.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt, test_58.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 2 ms 4352 KB
00_sample_02.txt AC 2 ms 4352 KB
00_sample_03.txt AC 2 ms 4352 KB
00_sample_04.txt AC 2 ms 4352 KB
00_sample_05.txt AC 2 ms 4352 KB
00_sample_06.txt AC 2 ms 4352 KB
00_sample_07.txt AC 2 ms 4352 KB
00_sample_08.txt AC 2 ms 4352 KB
test_01.txt AC 2 ms 4352 KB
test_02.txt AC 2 ms 4352 KB
test_03.txt AC 2 ms 4352 KB
test_04.txt AC 2 ms 4352 KB
test_05.txt AC 2 ms 4352 KB
test_06.txt AC 2 ms 4352 KB
test_07.txt AC 2 ms 4352 KB
test_08.txt AC 2 ms 4352 KB
test_09.txt AC 2 ms 4352 KB
test_10.txt AC 2 ms 4352 KB
test_11.txt AC 2 ms 4352 KB
test_12.txt AC 2 ms 4352 KB
test_13.txt AC 2 ms 4352 KB
test_14.txt AC 2 ms 4352 KB
test_15.txt AC 2 ms 4352 KB
test_16.txt AC 2 ms 4352 KB
test_17.txt AC 2 ms 4352 KB
test_18.txt AC 2 ms 4352 KB
test_19.txt AC 2 ms 4352 KB
test_20.txt AC 2 ms 4352 KB
test_21.txt AC 2 ms 4352 KB
test_22.txt AC 2 ms 4352 KB
test_23.txt AC 2 ms 4352 KB
test_24.txt AC 2 ms 4352 KB
test_25.txt AC 2 ms 4352 KB
test_26.txt AC 2 ms 4352 KB
test_27.txt AC 2 ms 4352 KB
test_28.txt AC 2 ms 4352 KB
test_29.txt AC 2 ms 4352 KB
test_30.txt AC 2 ms 4352 KB
test_31.txt AC 2 ms 4352 KB
test_32.txt AC 2 ms 4352 KB
test_33.txt AC 2 ms 4352 KB
test_34.txt AC 2 ms 4352 KB
test_35.txt AC 2 ms 4352 KB
test_36.txt AC 2 ms 4352 KB
test_37.txt AC 2 ms 4352 KB
test_38.txt AC 2 ms 4352 KB
test_39.txt AC 2 ms 4352 KB
test_40.txt AC 2 ms 4352 KB
test_41.txt AC 2 ms 4352 KB
test_42.txt AC 2 ms 4352 KB
test_43.txt AC 2 ms 4352 KB
test_44.txt AC 2 ms 4352 KB
test_45.txt AC 2 ms 4352 KB
test_46.txt AC 2 ms 4352 KB
test_47.txt AC 2 ms 4352 KB
test_48.txt AC 2 ms 4352 KB
test_49.txt AC 2 ms 4352 KB
test_50.txt AC 2 ms 4352 KB
test_51.txt AC 2 ms 4352 KB
test_52.txt AC 2 ms 4352 KB
test_53.txt AC 2 ms 4352 KB
test_54.txt AC 2 ms 4352 KB
test_55.txt AC 2 ms 4352 KB
test_56.txt AC 2 ms 4352 KB
test_57.txt AC 2 ms 4352 KB
test_58.txt AC 2 ms 4352 KB