Last active
January 9, 2016 15:46
-
-
Save whatalnk/2e262e9b59739b31294d to your computer and use it in GitHub Desktop.
AtCoder ABC 032
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
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 |
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 | |
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 |
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, 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 |
Author
whatalnk
commented
Jan 9, 2016
- 解説
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment