forked from sureshmangs/Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path483A - Counterexample.cpp
118 lines (79 loc) · 2.66 KB
/
483A - Counterexample.cpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
Your friend has recently learned about coprime numbers. A pair of numbers {a,?b} is called coprime if the maximum number that divides both a and b is equal to one.
Your friend often comes up with different statements. He has recently supposed that if the pair (a,?b) is coprime and the pair (b,?c) is coprime, then the pair (a,?c) is coprime.
You want to find a counterexample for your friend's statement. Therefore, your task is to find three distinct numbers (a,?b,?c), for which the statement is false, and the numbers meet the condition l?=?a?<?b?<?c?=?r.
More specifically, you need to find three numbers (a,?b,?c), such that l?=?a?<?b?<?c?=?r, pairs (a,?b) and (b,?c) are coprime, and pair (a,?c) is not coprime.
Input
The single line contains two positive space-separated integers l, r (1?=?l?=?r?=?1018; r?-?l?=?50).
Output
Print three positive space-separated integers a, b, c — three distinct numbers (a,?b,?c) that form the counterexample. If there are several solutions, you are allowed to print any of them. The numbers must be printed in ascending order.
If the counterexample does not exist, print the single number -1.
Examples
inputCopy
2 4
outputCopy
2 3 4
inputCopy
10 11
outputCopy
-1
inputCopy
900000000000000009 900000000000000029
outputCopy
900000000000000009 900000000000000010 900000000000000021
Note
In the first sample pair (2,?4) is not coprime and pairs (2,?3) and (3,?4) are.
In the second sample you cannot form a group of three distinct integers, so the answer is -1.
In the third sample it is easy to see that numbers 900000000000000009 and 900000000000000021 are divisible by three.
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll l, r;
cin >> l >> r;
if (l % 2 != 0) l++;
if (l + 2 > r) cout << -1;
else cout << l << " " << l + 1 << " " << l + 2;
return 0;
}
/*
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
if (a == 0) return b;
return gcd(b % a, a);
}
bool isCoprime(ll a, ll b) {
return gcd(a, b) == 1 ? true : false;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll l, r;
cin >> l >> r;
bool flag = false;
for (ll a = l; a < r; a++) {
for (ll b = a + 1; b < r; b++) {
if (isCoprime(a, b)) {
for (ll c = b + 1; c <= r; c++) {
if (isCoprime(b, c)) {
if (!isCoprime(a, c)) {
cout << a << " " << b << " " << c;
flag = true;
break;
}
}
}
}
if (flag) break;
}
if (flag) break;
}
if (!flag) cout << -1;
return 0;
}
*/