-
Notifications
You must be signed in to change notification settings - Fork 0
/
min max lcm pr 6.txt
80 lines (39 loc) · 1.51 KB
/
min max lcm pr 6.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Read problem statements in Mandarin Chinese, Russian, and Vietnamese as well.
You are given two positive integers X and K.
You have to output the minimum and maximum value of LCM(i,j) where X≤i<j≤X⋅K.
We define LCM(i,j) for two positive integers i and j as the minimum positive integer y such that both i and j divide y without remainder.
Input Format
First line will contain T, number of testcases. Then the testcases follow.
Each testcase contains of a single line of input, two space separated integers X and K.
Output Format
For each testcase, output two space separated integers - the minimum and maximum possible value respectively of LCM(i,j) where X≤i<j≤X⋅K.
Constraints
1≤T≤105
1≤X≤108
2≤K≤108
It is guaranteed that, for each test case, X⋅K≤109
Sample Input 1
2
4 3
2 3
Sample Output 1
8 132
4 30
Explanation
Test Case 1: We want to find the minimum and maximum value of LCM(i,j) for 4≤i<j≤12. It is easy to verify that the LCM(4,8)=8 is the minimum possible value whereas LCM(11,12)=132 is the maximum value.
Test Case 2: We want to find the minimum and maximum value of LCM(i,j) for 2≤i<j≤6. The maximum value is obtained for the pair (5,6) whereas the minimum is obtained for the pair (2,4).
// solution
#include <iostream>
using namespace std;
int main() {
// your code goes here
long long t;
cin >> t;
while(t--)
{
long long x,k;
cin >> x >> k;
cout << 2 * x << " " ;
cout <<(x*k-1)*x*k << " " << endl;
}
}