14 atcoder#ABC120B. [ABC120B] K-th Common Divisor
[ABC120B] K-th Common Divisor
Score : points
Problem Statement
You are given positive integers and .
Find the -th largest positive integer that divides both and .
The input guarantees that there exists such a number.
Constraints
- All values in input are integers.
- The -th largest positive integer that divides both and exists.
Input
Input is given from Standard Input in the following format:
Output
Print the -th largest positive integer that divides both and .
8 12 2
2
Three positive integers divides both and : and . Among them, the second largest is .
100 50 4
5
1 1 1
1