結果
| 問題 |
No.207 世界のなんとか
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-22 10:36:00 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 966 bytes |
| コンパイル時間 | 12,400 ms |
| コンパイル使用メモリ | 403,696 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-21 09:15:13 |
| 合計ジャッジ時間 | 13,512 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
use std::io::{self, BufReader, BufWriter, Read, Write};
fn main() {
let stdin = io::stdin();
let mut stdin = BufReader::new(stdin.lock());
let stdout = io::stdout();
let mut stdout = BufWriter::new(stdout.lock());
let a = read_u64(&mut stdin);
let b = read_u64(&mut stdin);
(a..b + 1)
.filter(|x| is_multiple_of_three(*x) || is_include_three(*x))
.for_each(|x| writeln!(&mut stdout, "{}", x).unwrap());
}
fn read_u64<R: Read>(reader: &mut R) -> u64 {
reader
.bytes()
.filter_map(|b| b.ok())
.skip_while(|b| b.is_ascii_whitespace())
.take_while(|b| !b.is_ascii_whitespace())
.map(|b| (b - 48) as u64)
.fold(0, |acc, x| acc * 10 + x)
}
fn is_multiple_of_three(x: u64) -> bool {
x % 3 == 0
}
fn is_include_three(x: u64) -> bool {
let mut n = x;
while n != 0 {
if n % 10 == 3 {
return true;
}
n /= 10;
}
false
}