Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
a^2 + b^2 == c^2 かつ a+b+c=1000, a < b < c となる a, b, c を求める (流石にナイーブすぎて遅いバージョン)
(1..1000).each { |i|
(1..1000).each { |j|
(1..1000).each { |k|
next if j <= i
next if k <= j
next if i+j+k != 1000
puts "#{i}, #{j}, #{k}" if i*i + j*j == k*k
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.