Create a gist now

Instantly share code, notes, and snippets.

AtCoder ABC 032
a = gets.chomp.to_i
b = gets.chomp.to_i
n = gets.chomp.to_i
a, b = [a, b].minmax
i = n / b
while true
m = i * b
if (m >= n) && (m % a == 0) then
puts m
break
else
i += 1
end
end
s = gets.chomp
k = gets.chomp.to_i
ks = []
n = s.length
if k > n then
puts 0
else
(0..(n - k)).each do |i|
ks << s[i, k]
end
puts ks.uniq.length
end
n, k = gets.chomp.split(" ").map(&:to_i)
ss = readlines.map(&:to_i)
if ss.include?(0) then
puts n
exit
end
left = 0
right = 0
res = 0
num = ss[0]
while true
if num <= k then
res = [res, right - left + 1].max
if right < n - 1 then
right += 1
num *= ss[right]
else
break
end
else
if right >= n - 1 then
break
elsif left == right then
left += 1
right += 1
num = ss[left]
else
num /= ss[left]
left += 1
end
end
end
puts res
# from Submission #606429
@whatalnk
Owner
whatalnk commented Jan 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment