結果
| 問題 |
No.207 世界のなんとか
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-17 15:52:47 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,135 bytes |
| コンパイル時間 | 14,942 ms |
| コンパイル使用メモリ | 379,788 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 03:50:59 |
| 合計ジャッジ時間 | 12,266 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 19 |
ソースコード
fn getline() -> String {
let mut a = String::new();
std::io::stdin().read_line(&mut a).ok();
return a;
}
fn main() {
let input = getline();
let splited: Vec<&str> = input.split(" ").collect();
let a = splited[0].parse::<u32>().unwrap();
let b = splited[1].parse::<u32>().unwrap();
let result = logic(a, b);
for i in result.iter() {
println!("{}", i);
}
}
fn check_three(x: u32) -> bool {
let s = x.to_string();
for char in s.chars() {
if char == '3' {
return true;
}
}
return false;
}
#[test]
fn test_check_three() {
let a = check_three(132);
assert_eq!(a, true);
let a = check_three(568468);
assert_eq!(a, false);
}
fn logic(a: u32, b: u32) -> Vec<u32> {
let mut res: Vec<u32> = vec![];
for i in a..b+1 {
if i % 3 == 0 {
res.push(i);
} else if check_three(i){
res.push(i);
}
}
return res;
}
#[test]
fn test_logic() {
let res = logic(1, 10);
assert_eq!(res, vec![3, 6, 9]);
let res = logic(10, 20);
assert_eq!(res, vec![12, 13, 15, 18]);
}