fork download
  1. f = -> m {
  2. (1..Float::INFINITY).each_with_object(Hash.new {|h, k| h[k] = []}) {|a, acc|
  3. (1...a).each {|b|
  4. c = a * a * a - b * b * b
  5. acc[c] << [a, b]
  6. return acc[c] if acc[c].size == m
  7. }
  8. }
  9. }
  10. p f.(5) # [[1134, 357], [1155, 504], [1246, 805], [2115, 2004], [4746, 4725]]
Time limit exceeded #stdin #stdout 5s 655408KB
stdin
Standard input is empty
stdout
Standard output is empty