Coin de Gamma
1 year ago
1 changed files with 31 additions and 0 deletions
@ -0,0 +1,31 @@
|
||||
use std::collections::HashSet; |
||||
|
||||
fn main() { |
||||
let mut hs = HashSet::new(); |
||||
for n in 1..10000 { |
||||
let pn = n * ( 3*n -1 ) / 2; |
||||
hs.insert(pn); |
||||
} |
||||
let mut D = 10000000; |
||||
for p in hs.iter() { |
||||
for q in hs.iter() { |
||||
if q <= p { |
||||
continue; |
||||
} |
||||
|
||||
let s = *p + *q; |
||||
if !hs.contains(&s) { |
||||
continue; |
||||
} |
||||
let d = *q - *p; |
||||
if !hs.contains(&d) { |
||||
continue; |
||||
} |
||||
if d < D { |
||||
D = d; |
||||
} |
||||
} |
||||
} |
||||
println!("{}", D); |
||||
|
||||
} |
Loading…
Reference in new issue