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. APPScan手动探索

  2. (Eclipse) 安装Subversion1.82(SVN)插件

    简介    :SVN是团队开发的代码管理工具,它使我们得以进行多人在同一平台之下的团队开发. 解决问题:Eclipse下的的SVN插件安装. 学到    :Eclipse下的的SVN插件安装. 资源地 ...

  3. 联想 Z470个人安装黑苹果参考

    笔记本是联想 Z470,cpu i3-2350M 傻瓜图文式]Win系统下制作U盘CLOVER引导 EDIT部分 进去黑屏 U盘引导盘

  4. 【一坨理论AC的题】Orz sxy大佬

    1.UVA10891 Game of Sum 2.LA4254 Processor . 3.UVA10905 Children's Game 4.UVA11389 The Bus Driver Pro ...

  5. PHP--通用化API接口数据输出 封装

    /** * 通用化API接口数据输出 * author qinpeizhou * @param $message * @param array $data * @param int $httpCode ...

  6. php条件语句(一)

    PHP If...Else 语句 条件语句用于根据不同条件执行不同动作. PHP 条件语句 当您编写代码时,您常常需要为不同的判断执行不同的动作.您可以在代码中使用条件语句来完成此任务. 在 PHP ...

  7. 使用video.js支持flv格式

    html5的video标签只支持mp4.webm.ogg三种格式,不支持flv格式,在使用video.js时,如果使用html5是会报错不支持. 修改了一下代码 js部分 videojs.option ...

  8. HTML入门:Tag学习

    即使 <br> 在所有浏览器中的显示都没有问题,使用 <br /> 也是更长远的保障. 标签 描述 <html> 定义 HTML 文档. <body> ...

  9. VC++ ComBox下拉菜单看不到值

    在使用ComBox的时候,我是预先在属性页里面添加了数据的.但是在运行程序是发现,点击下拉时,一个值都看不到! 如图: 在这:http://blog.csdn.net/nma_123456/artic ...

  10. Device eth0 does not seem to be present, delaying initialization(VM虚拟机restart service出现此错误)

    >从vmware workstation中克隆(clone)了一个redhat6.0的虚拟机,启动之后发现网卡没有启动.于是重启一下network服务,发现提示错误信息“Device eth0 ...