#abc341d. D - Only one of two

D - Only one of two

Score: 400400 points

问题描述

给定三个正整数 NNMMKK,其中 NNMM 是不同的。 输出第 KK 小的仅能被 NNMM恰好一个整除的正整数。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given three positive integers NN, MM, and KK. Here, NN and MM are different. Print the KK-th smallest positive integer divisible by exactly one of NN and MM.

Constraints

  • 1N,M1081 \leq N, M \leq 10^8
  • 1K10101 \leq K \leq 10^{10}
  • NMN \neq M
  • NN, MM, and KK are integers.

Input

The input is given from Standard Input in the following format:

NN MM KK

Output

Print the KK-th smallest positive integer divisible by exactly one of NN and MM.

Sample Input 1

2 3 5

Sample Output 1

9

The positive integers divisible by exactly one of 22 and 33 are 2,3,4,8,9,10,2, 3, 4, 8, 9, 10, \ldots in ascending order. Note that 66 is not included because it is divisible by both 22 and 33. The fifth smallest positive integer that satisfies the condition is 99, so we print 99.

Sample Input 2

1 2 3

Sample Output 2

5

The numbers that satisfy the condition are 1,3,5,7,1, 3, 5, 7, \ldots in ascending order.

Sample Input 3

100000000 99999999 10000000000

Sample Output 3

500000002500000000

update @ 2024/3/10 01:34:48