結果
| 問題 |
No.2920 Blood Type
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 15:06:59 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 786 bytes |
| コンパイル時間 | 12,635 ms |
| コンパイル使用メモリ | 379,836 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 15:07:16 |
| 合計ジャッジ時間 | 13,753 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
ソースコード
use proconio::input;
fn main() {
input! {
s: String,
t: String,
}
let mut sum_per_type = [0_u8; 4];
for type1 in s.chars() {
for type2 in t.chars() {
let type_pair = [type1, type2];
let child_type = calculate_child_type(type_pair);
sum_per_type[child_type] += 1;
}
}
let [a, b, ab, o] = sum_per_type.map(|sum| 100.0 * sum as f64 / 4.0);
println!("{} {} {} {}", a, b, ab, o);
}
fn calculate_child_type(type_pair: [char; 2]) -> usize {
let contains_a = type_pair.contains(&'A');
let contains_b = type_pair.contains(&'B');
match (contains_a, contains_b) {
(true, true) => 2,
(true, false) => 0,
(false, true) => 1,
(false, false) => 3,
}
}