Coin de Gamma
12 months ago
1 changed files with 39 additions and 0 deletions
@ -0,0 +1,39 @@
|
||||
use std::collections::HashMap; |
||||
fn get_hs(n: u32) -> HashMap<u8, u32> { |
||||
let mut nn = n; |
||||
let mut res = HashMap::<u8, u32>::new(); |
||||
while nn > 0 { |
||||
let c = (nn%10) as u8; |
||||
if res.contains_key(&c) { |
||||
res.insert(c, res[&c] + 1); |
||||
} else { |
||||
res.insert(c, 1); |
||||
} |
||||
nn /= 10; |
||||
} |
||||
return res; |
||||
} |
||||
|
||||
|
||||
fn test(n: u32) -> bool { |
||||
let hm = get_hs(n); |
||||
for i in 2..=6 { |
||||
let m = n * i; |
||||
let hmi = get_hs(m); |
||||
if hmi != hm { |
||||
return false; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
fn main() { |
||||
for i in 1..999999 { |
||||
|
||||
if test(i) { |
||||
println!("{}", i); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue