PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000014. Số thứ k không chia hết cho n (K-th Not Divisible by n)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Số thứ k không chia hết cho n (K-th Not Divisible by n)
K-th Not Divisible by n
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers and , consider all positive integers not divisible by , in increasing order. Find the -th number in this sequence.
Input
One line contains and .
Output
Print the -th positive integer not divisible by .
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
3 7
Output
10
Explanation
The sequence is , so the seventh element is .