Browse Source

052 ok

master
Coin de Gamma 12 months ago
parent
commit
baaf922cde
  1. 39
      052/main.rs

39
052/main.rs

@ -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…
Cancel
Save