結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー seinyanseinyan
提出日時 2021-11-05 22:11:41
言語 Rust
(1.77.0)
結果
RE  
実行時間 -
コード長 716 bytes
コンパイル時間 1,006 ms
コンパイル使用メモリ 170,380 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-24 05:58:39
合計ジャッジ時間 1,883 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 0 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 1 ms
6,944 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 0 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unnecessary parentheses around index expression
  --> main.rs:21:11
   |
21 |         v[(i as usize - 48)] += 1;
   |           ^               ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
21 -         v[(i as usize - 48)] += 1;
21 +         v[i as usize - 48] += 1;
   |

warning: 1 warning emitted

ソースコード

diff #

use std::usize;

fn input_line<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = input_line::<String>();
    let n: u128 = u128::from_str_radix(&n[0], 16).unwrap();

    let num_ch: Vec<char> = format!("{:o}", n).chars().collect();

    let mut v = vec![0; 9];

    for i in num_ch {
        v[(i as usize - 48)] += 1;
    }

    let mut max: u128 = 0;
    for i in &v {
        if *i > max {
            max = *i;
        }
    }

    for i in 0..9 {
        if v[i] == max {
            print!("{} ", i);
        }
    }
}
0