Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
AtCoder ABC #068 / ARC #079
puts "ABC" + gets.chomp
n = gets.chomp.to_i
ans = 1
ndiv = 0
(1..n).each do |i|
x = i
if x.even?
tmp = 1
while x.even?
x /= 2
tmp += 1
end
if tmp > ndiv
ndiv = tmp
ans = i
end
end
end
puts ans
n, m = gets.chomp.split(" ").map(&:to_i)
cand = []
ship = Array.new(n+1, false)
m.times do
a, b = gets.chomp.split(" ").map(&:to_i)
if b == n then
cand << a
elsif a == 1 then
ship[b] = true
end
end
cand.each do |i|
if ship[i]
puts "POSSIBLE"
exit
end
end
puts "IMPOSSIBLE"
k = gets.chomp.to_i
n = 50
ret = (0...n).to_a
x = k / n
rem = k % n
ret.map!{|i| i + x}
rem.times do |i|
amin = ret.min
imin = ret.index(amin)
ret.map!{|e| e - 1}
ret[imin] += (n + 1)
end
puts n
puts ret.join(" ")
n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)
ret = 0
while arr.max >= n
s = arr.map{|x| x / n}.inject(:+)
arr.map!{|x| x + s - (n+1)*(x / n)}
ret += s
end
puts ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment