Coin de Gamma
1 year ago
1 changed files with 44 additions and 0 deletions
@ -0,0 +1,44 @@
|
||||
use std::collections::HashSet; |
||||
|
||||
fn pr(s: &Vec<u8>) { |
||||
for c in s.iter() { print!("{}", c); } |
||||
println!(""); |
||||
} |
||||
|
||||
fn dv(k: u32) -> Vec<u8> { |
||||
let mut rms = HashSet::new(); |
||||
let mut res: Vec<u8> = Vec::new(); |
||||
let mut n = 1u32; |
||||
loop { |
||||
if rms.contains(&n) { |
||||
break; |
||||
} |
||||
rms.insert(n); |
||||
if n == 0 { res.clear(); res.push(0); break; } |
||||
while n < k { n *= 10; res.push(0u8); } |
||||
let m = n / k; |
||||
if m > 10 { |
||||
println!("fail! {}", m); |
||||
} |
||||
res.pop(); |
||||
//print!("{}", m);
|
||||
res.push(m as u8); |
||||
n = n - m * k; |
||||
} |
||||
return res; |
||||
} |
||||
|
||||
fn main() { |
||||
let mut max = 0; |
||||
let mut max_d = 0; |
||||
for i in 1..1000 { |
||||
let r = dv(i); |
||||
if r.len() > max { |
||||
max_d = i; |
||||
max = r.len(); |
||||
} |
||||
//pr(&r);
|
||||
} |
||||
println!("{}", max_d); |
||||
} |
||||
|
Loading…
Reference in new issue