結果

問題 No.661 ハローキティはりんご3個分
ユーザー hitoyozakehitoyozake
提出日時 2018-04-14 00:01:19
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,777 bytes
コンパイル時間 1,311 ms
コンパイル使用メモリ 151,424 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 04:52:49
合計ジャッジ時間 1,915 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

warning: unused import: `Read`
 --> Main.rs:3:21
  |
3 | use std::io::{self, Read};
  |                     ^^^^

warning: unnecessary parentheses around type
 --> Main.rs:5:24
  |
5 | fn getline() -> Result<(String)> {
  |                        ^      ^
  |
  = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
  |
5 - fn getline() -> Result<(String)> {
5 + fn getline() -> Result<String> {
  |

warning: unnecessary parentheses around function argument
  --> Main.rs:10:8
   |
10 |     Ok((buffer))
   |        ^      ^
   |
help: remove these parentheses
   |
10 -     Ok((buffer))
10 +     Ok(buffer)
   |

warning: unused variable: `x`
 --> Main.rs:8:9
  |
8 |     let x = io::stdin().read_line(&mut buffer)?;
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `a`
  --> Main.rs:20:21
   |
20 |             let mut a = "";  
   |                     ^ help: if this is intentional, prefix it with an underscore: `_a`

warning: unused variable: `i`
  --> Main.rs:21:17
   |
21 |             for i in 0..m{
   |                 ^ help: if this is intentional, prefix it with an underscore: `_i`

warning: unused variable: `err`
  --> Main.rs:42:25
   |
42 |                     Err(err) =>{},
   |                         ^^^ help: if this is intentional, prefix it with an underscore: `_err`

warning: unused variable: `err`
  --> Main.rs:49:13
   |
49 |         Err(err)=>{},
   |             ^^^ help: if this is intentional, prefix it with an underscore: `_err`

warning: variable does not need to be mutable
  --> Main.rs:20:17
   |
20 |             let mut a = "";  
   |                 ----^
   |                 |
   |                 help: remove this `mut`
   |
   = note: `#[warn(unused_mut)

ソースコード

diff #

use std::io::*;
use std::str::*;
use std::io::{self, Read};

fn getline() -> Result<(String)> {
    let mut buffer = String::new();
    // ? はtry!の糖衣構文
    let x = io::stdin().read_line(&mut buffer)?;
    //println!("{}", x); // xは入力byte数
    Ok((buffer))
}

fn main() {
    let n = getline();
    let mut vec = Vec::new(); 
    match n {
        Ok(buf) => {
            
            let m :u32 = buf.trim().parse::<u32>().unwrap();
            let mut a = "";  
            for i in 0..m{
                let apples = getline();

                match apples{
                    Ok(b) => {
                      let apple_n = (b.trim().parse::<u32>().unwrap())/3; 
                      let row = b.trim().parse::<u32>().unwrap();
                        if row%8 ==0&& row%10==0{
                          vec.push("ikisugi".to_string());
                        }
                        else if row % 8 == 0 {
                            vec.push("iki".to_string());
                        }
                        else if row%10==0{
                            vec.push("sugi".to_string());
                        }
                        else {
                        
                            vec.push(apple_n.to_string());
                        }
                    }
                    Err(err) =>{},
        
                }
            }
        
        }

        Err(err)=>{},
    }
    for i in vec{
        println!("{}", i);
    }

    /*
    let n = getline();
    match n {
        Ok(buf) => {
            println!("input is {}", buf);
            let sp = buf.split(" ");
            for s in sp{
               println!("{}", s);
            }
        }
        Err(error) => println!("error is {}", error),
    }*/

}
0