Codeforces A. Counterexample
//Next Codeforces Round #354 (Div. 2)
#include<bits/stdc++.h>
//#include<cstdio>
//#include<iostream>
//#include<algorithm>
//#include<vector>
//#include<cstring>
//#include<cmath>
//#include<map>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
LL gcd(LL a , LL b)
{
return b != 0 ? gcd(b , a%b) : a;
}
int main()
{
fast;
LL l , r , i , a , b , c , j;
while(cin >> l >> r)
{
if(r - l < 2)
{
cout << "-1\n";
continue;
}
a = b = c = 0;
for(i=l; i<=r-1; i++)
{
if(gcd(i, i+1) == 1)
{
//cout << i << " " << i+1 << "\n";
a = i;
b = i+1;
//cout << a << " " << b << " ";
for(j=b+1; j<=r; j++)
{
if(gcd(a,j) > 1 and gcd(b,j)==1)
{
c = j;
break;
}
}
}
if(c > 0) break;
}
//cout << "c = " << c << "; ";
if(a==0 or b==0 or c==0) outn("-1");
else cout << a << " " << b << " " << c << "\n";
}
return 0;
}
#include<bits/stdc++.h>
//#include<cstdio>
//#include<iostream>
//#include<algorithm>
//#include<vector>
//#include<cstring>
//#include<cmath>
//#include<map>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
LL gcd(LL a , LL b)
{
return b != 0 ? gcd(b , a%b) : a;
}
int main()
{
fast;
LL l , r , i , a , b , c , j;
while(cin >> l >> r)
{
if(r - l < 2)
{
cout << "-1\n";
continue;
}
a = b = c = 0;
for(i=l; i<=r-1; i++)
{
if(gcd(i, i+1) == 1)
{
//cout << i << " " << i+1 << "\n";
a = i;
b = i+1;
//cout << a << " " << b << " ";
for(j=b+1; j<=r; j++)
{
if(gcd(a,j) > 1 and gcd(b,j)==1)
{
c = j;
break;
}
}
}
if(c > 0) break;
}
//cout << "c = " << c << "; ";
if(a==0 or b==0 or c==0) outn("-1");
else cout << a << " " << b << " " << c << "\n";
}
return 0;
}
Comments
Post a Comment