Created
March 4, 2019 12:49
-
-
Save whatalnk/dcda64240852bfdd4783b9c5a6e79dec to your computer and use it in GitHub Desktop.
AtCoder ABC #120 B. K-th Common Divisor
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, b, k = gets.chomp.split(" ").map(&:to_i) | |
ret = [] | |
c = [a, b].min | |
1.upto(c) do |i| | |
if a % i == 0 && b % i == 0 | |
ret << i | |
end | |
end | |
puts ret.reverse[k - 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment