結果
| 問題 |
No.207 世界のなんとか
|
| コンテスト | |
| ユーザー |
kn_rew
|
| 提出日時 | 2025-01-06 22:59:57 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 2,403 bytes |
| コンパイル時間 | 14,179 ms |
| コンパイル使用メモリ | 399,992 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-06 23:00:12 |
| 合計ジャッジ時間 | 11,587 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
use proconio::{fastout, input};
use reprol::math::radix::ToRadix;
#[fastout]
fn main() {
input! {
a: u64,
b: u64,
}
for x in a..=b {
if x % 3 == 0 || x.to_radix(10).contains(&3) {
println!("{}", x);
}
}
}
#[allow(dead_code)]
mod reprol {
pub mod math {
pub mod radix {
pub trait ToRadix {
fn to_radix(self, base: Self) -> Vec<u32>;
}
pub trait FromRadix {
type Output;
fn from_radix(&self, n: u32) -> Self::Output;
}
macro_rules! impl_integer {
($($ty:ident),*) => {$(
impl ToRadix for $ty {
fn to_radix(self, base: Self) -> Vec<u32> {
if self == 0 {
return vec![0];
}
let mut n = self;
let mut res = Vec::new();
while n > 0 {
let x = (n % base) as u32;
res.push(x);
n /= base;
}
res.reverse();
res
}
}
)*};
}
impl_integer!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize);
impl FromRadix for String {
type Output = u64;
fn from_radix(&self, n: u32) -> Self::Output {
u64::from_str_radix(self, n).unwrap()
}
}
impl FromRadix for &str {
type Output = u64;
fn from_radix(&self, n: u32) -> Self::Output {
u64::from_str_radix(self, n).unwrap()
}
}
impl FromRadix for Vec<u32> {
type Output = u64;
fn from_radix(&self, n: u32) -> Self::Output {
let n = n as u64;
let mut res = 0;
let mut base = 1;
for &e in self.iter().rev() {
res += e as u64 * base;
base *= n;
}
res
}
}
}
}
}
kn_rew