#ABC120B. K-th Common Divisor

K-th Common Divisor

题目描述

You are given positive integers AA and BB.

Find the KK-th largest positive integer that divides both AA and BB.

The input guarantees that there exists such a number.

给你正整数 AA 和 BB 。

求同时整除 AA 和 BB 的 KK -th 最大正整数。

输入保证存在这样一个数。

输入格式

输入内容按以下格式标准输入:

AA BB KK

输出格式

打印同时整除 AA 和 BB 的 KK -th 最大正整数。

样例 #1

样例输入 #1

8 12 2

样例输出 #1

2

样例 #2

样例输入 #2

100 50 4

样例输出 #2

5

样例 #3

样例输入 #3

1 1 1

样例输出 #3

1

说明

数据规模与约定

  • 输入值均为整数
  • 1≤A,B≤1001 \leq A, B \leq 100
  • 同时除以 AA 和 BB 的 KK -th 最大正整数存在。
  • K≥1K \geq 1

样例 11 解释

三个正整数能同时整除 88 和 1212 : 1,21, 2 和 44 。其中,第二大的数是 22 。