Created
October 1, 2017 09:21
-
-
Save whatalnk/0b3cbf56de1e753d8eabcd4b64d4448a to your computer and use it in GitHub Desktop.
天下一プログラマーコンテスト2017
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts gets.chomp.split("").map(&:to_i).inject(:+) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = gets.chomp.to_i | |
arr = [] | |
n.times do | |
a, b = gets.chomp.split(" ").map(&:to_i) | |
arr << [a, b] | |
end | |
arr.sort_by!{|x| x[0]} | |
puts arr.last[0] + arr.last[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = gets.chomp.to_i | |
if N.even? | |
# p [N / 4, N * N * (N / 2) / (N * N + N * N / 2 + N * N / 2)] | |
puts "#{N} #{N} #{N / 2}" | |
else | |
(1..3500).each do |h| | |
(1..3500).each do |n| | |
if h.even? || n.even? then | |
x = N * h * n | |
y = (4 * h * n - N * n - N * h) | |
if y > 0 && x % y == 0 | |
# p [N / 4, h * n * (x / y) / (h * n + n * x / y + h * x / y)] | |
puts "#{h} #{n} #{x / y}" | |
exit | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment