Last active
February 7, 2016 05:33
-
-
Save whatalnk/78da27421517dcc2cea4 to your computer and use it in GitHub Desktop.
AtCoder ABC #033
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.split("") | |
if n.uniq.length == 1 then | |
puts "SAME" | |
else | |
puts "DIFFERENT" | |
end |
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 | |
towns = [] | |
populations = [] | |
sum = 0 | |
n.times do | |
s, p = gets.chomp.split(" ") | |
p = p.to_i | |
sum += p | |
towns << s | |
populations << p | |
end | |
n.times do |i| | |
if populations[i] * 2 > sum then | |
puts towns[i] | |
exit | |
end | |
end | |
puts "atcoder" |
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
s = gets.chomp.split("+") | |
res = 0 | |
s.each do |i| | |
if i.length == 1 then | |
if i != "0" then | |
res += 1 | |
end | |
else | |
res += 1 if not i.include?("0") | |
end | |
end | |
puts res |
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 | |
x = [] | |
y = [] | |
n.times do | |
tmp = gets.chomp.split(" ").map(&:to_i) | |
x << tmp[0] | |
y << tmp[1] | |
end | |
eps = 1e-12 | |
mid = 0 | |
high = 0 | |
n.times do |i| | |
l = [] | |
n.times do |j| | |
if i != j then | |
l << Math.atan2(y[i] - y[j], x[i] - x[j]) | |
end | |
end | |
l.sort! | |
pointer = [0, 0, 0] | |
diff = [Math::PI / 2 - eps, Math::PI / 2 + eps, Math::PI - eps] | |
l.length.times do |j| | |
diff.length.times do |k| | |
while true | |
rad = l[pointer[k] % l.length] + Math::PI * 2 * (pointer[k] / l.length) - l[j] | |
if rad < diff[k] then | |
pointer[k] += 1 | |
else | |
break | |
end | |
end | |
end | |
mid += pointer[1] - pointer[0] | |
high += pointer[2] - pointer[1] | |
end | |
end | |
low = n * (n-1) * (n-2) / 6 - (mid + high) | |
puts [low, mid, high].join(" ") | |
# ref: Submission #631150 | |
# TLE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment