結果

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

テストケース

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

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

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

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

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