PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000238. Phần tử thứ k nguyên tố cùng nhau với p (List Of Integers)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Phần tử thứ k nguyên tố cùng nhau với p (List Of Integers)
Phần tử thứ k nguyên tố cùng nhau với p (List Of Integers)
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
For each query , consider the increasing sequence of integers satisfying . Output its -th element.
Input
- First line: number of queries .
- Each of the next lines contains .
Output
Print one integer answer per query.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
3
7 22 1
7 22 2
7 22 3
Output
9
13
15
Explanation
The first three integers greater than 7 and coprime with 22 are 9, 13, and 15.
Example 2
Input
1
1 1 5
Output
6
Explanation
Every integer is coprime with 1, so the fifth integer after 1 is 6.