PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000023. Orac và phép cộng ước nhỏ nhất (Orac and Factors)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Orac và phép cộng ước nhỏ nhất (Orac and Factors)
Orac and Factors
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
For any integer , let denote its smallest positive divisor greater than . For example, , , and . Start with integer and perform exactly operations, each replacing the current value by . The divisor is recomputed from the current value after each update. Print the final value.
Input
One line contains integers and , in that order.
Output
Print one integer: the value after exactly operations.
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Examples
Input
5 1
Output
10
Explanation
Since is prime, . The single operation produces , so print 10.
Input
8 2
Output
12
Explanation
At step , gives . At step , recompute and obtain . Print 12.
Input
3 4
Output
12
Explanation
Starting from , the four successive values are , since and all later numbers are even with smallest divisor .