結果
問題 |
No.207 世界のなんとか
|
ユーザー |
|
提出日時 | 2022-11-17 15:53:25 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 1,142 bytes |
コンパイル時間 | 10,714 ms |
コンパイル使用メモリ | 403,132 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 03:52:19 |
合計ジャッジ時間 | 11,643 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 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.trim().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]); }