A. Counterexample
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 lr (1 ≤ l ≤ r ≤ 1018; r - l ≤ 50).

Output

Print three positive space-separated integers abc — 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
input
2 4
output
2 3 4
input
10 11
output
-1
input
900000000000000009 900000000000000029
output
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.

【题意】:是否存在连续的序列a b c 满足a和b以及b和c最大公约数为1,而a和c最大公约数不为1。

【分析】:3重for循环暴力枚举,注意不要爆int,都要long long

【代码】:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 65535+10
ll x,y,z;
int f;
ll gcd(ll a ,ll b)
{
return b?gcd(b,a%b):a;
} int main()
{
ll n,m;
f=0;
cin>>n>>m;
for(ll i=n;i<=m;i++)
{
for(ll j=i+1;j<=m;j++)
{
for(ll k=j+1;k<=m;k++)
{
if((gcd(i,j)==1)&&(gcd(j,k)==1)&&(gcd(i,k)!=1))
{
x=i;
y=j;
z=k;
f=1;
break;
}
}
if(f) break;
}
if(f) break;
}
if(f) printf("%lld %lld %lld\n",x,y,z);//
else printf("-1\n");
}

  

Codeforces Round #275 (Div. 2) A. Counterexample【数论/最大公约数】的更多相关文章

  1. Codeforces Round #275 (Div. 2)-A. Counterexample

    http://codeforces.com/contest/483/problem/A A. Counterexample time limit per test 1 second memory li ...

  2. Codeforces Round #275 (Div. 2) C - Diverse Permutation (构造)

    题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n.求一个序列当中相邻两项差的绝对值的个数(指绝对值不同的个数 ...

  3. Codeforces Round #275 (Div. 1)A. Diverse Permutation 构造

    Codeforces Round #275 (Div. 1)A. Diverse Permutation Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 ht ...

  4. 构造 Codeforces Round #275 (Div. 2) C. Diverse Permutation

    题目传送门 /* 构造:首先先选好k个不同的值,从1到k,按要求把数字放好,其余的随便放.因为是绝对差值,从n开始一下一上, 这样保证不会超出边界并且以防其余的数相邻绝对值差>k */ /*** ...

  5. [Codeforces Round #275 (Div. 2)]B - Friends and Presents

    最近一直在做 codeforces ,总觉得已经刷不动 BZOJ 了? ——真是弱喵 你看连 Div.2 的 B 题都要谢谢题解,不是闲就是傻 显然我没那么闲 ╮(╯_╰)╭ 我觉得这题的想法挺妙的~ ...

  6. Codeforces Round #275 (Div. 2)

    A. Counterexample 题意:给出l,r,找出使得满足l<a<b<c<r,同时满足a,b的最大公约数为1,b,c的最大公约数为1,且a,b的最大公约数不为1 因为题 ...

  7. Codeforces Round #338 (Div. 2) D. Multipliers 数论

    D. Multipliers 题目连接: http://codeforces.com/contest/615/problem/D Description Ayrat has number n, rep ...

  8. Codeforces Round #275 (Div. 2) A,B,C,D

    A. Counterexample time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  9. Codeforces Round #275 (Div. 2) C

    题目传送门:http://codeforces.com/contest/483/problem/C 题意分析:题目意思没啥好说的. 去搞排列列举必须TLE.那么就想到构造. 1.n.2.n-1.3.n ...

随机推荐

  1. python的functools.partial的应用

    functools.partial是类似于创造“可移动”函数的意思,参数的第一个是函数名,其他的是这个函数其他参数,例如: generator_func = functools.partial( tf ...

  2. Umount- Linux必学的60个命令

    1.作用 umount命令的作用是卸载一个文件系统,它的使用权限是超级用户或/etc/fstab中允许的使用者. 2.格式 unmount -a [-fFnrsvw] [-t vfstype] [-n ...

  3. 廖雪峰Java10加密与安全-3摘要算法-3SHA-1算法

    1.SHA-1算法 SHA-1算法也是一种哈希算法. 输出160 bits/20bytes 由美国国家安全局开发 SHA-0/SHA-1/SHA-256/SHA-512 * SHA-0有问题,已经作废 ...

  4. c++设计模式:观察者模式

    主要思想:建立一个一对多的关系,当一个对象发生发生变化时,其他对象也发生变化. 可以举个博客订阅的例子,当博主发表新文章的时候,即博主状态发生了改 变,那些订阅的读者就会收到通知,然后进行相应的动作, ...

  5. Delphi 设计模式:《HeadFirst设计模式》Delphi代码---模式小结之一个叫声接口和几只鸭子[转]

    一.一个叫声接口和几只鸭子 从一个叫声接口开始. {<HeadFirst设计模式>Delphi代码之模式小结 } { 一个叫声接口                            } ...

  6. 高性能非阻塞 Web 服务器 Undertow

    Undertow 简介 Undertow是一个用java编写的.灵活的.高性能的Web服务器,提供基于NIO的阻塞和非阻塞API. Undertow的架构是组合式的,可以通过组合各种小型的目的单一的处 ...

  7. 2019-4-17-从-dotnet-core-3.0-的特性让-WPF-布局失效讨论-API-兼容

    title author date CreateTime categories 从 dotnet core 3.0 的特性让 WPF 布局失效讨论 API 兼容 lindexi 2019-4-17 1 ...

  8. HDFS 块

  9. PyCharm在同一个包(package)下,如何把一个.py文件导入另外一个.py文件下

    PyCharm在同一个包(package)下,如何把一个.py文件导入另外一个.py文件下 在同一个包下只需要用import 掉以后就可以找到模块所在的位置,但是如果不在同一个包下,在需要返回父级调用 ...

  10. LUOGU P3024 [USACO11OPEN]奶牛跳棋Cow Checkers

    题目描述 One day, Bessie decides to challenge Farmer John to a game of ‘Cow Checkers’. The game is playe ...