http://codeforces.com/contest/483/problem/A

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.

Sample test(s)
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.

解题思路:因为r-l <= 50,所以三重for循环暴力即可

 1 #include <stdio.h>
 2 
 3 #define ll long long
 4 
 5 ll gcd(ll a, ll b){
 6     ll t;
 7     while(b > ){
 8         t = a % b; a = b; b = t;
 9     }
     return a;
 }
 
 int main(){
     ll a, b, c, l, r, i, j, k;
     int flag;
     while(scanf("%I64d %I64d", &l, &r) != EOF){
         flag = ;
         for(i = l; i < r - ; i++){
             a = i;
             for(j = i + ; j < r; j++){
                 b = j;
                 for(k = j + ; k <= r; k++){
                     c = k;
                     if(gcd(a, b) ==  && gcd(b, c) ==  && gcd(a, c) != ){
                         flag = ;
                     }
                     if(flag == ) break;
                 }
                 if(flag == ) break;
             }
             if(flag == ) break;
         }
         if(flag == ){
             printf("%I64d %I64d %I64d\n", a, b, c);
         }
         else{
             printf("-1\n");
         }
     }
     return ;

41 }

Codeforces Round #275 (Div. 2)-A. Counterexample的更多相关文章

  1. Codeforces Round #275 (Div. 2) A. Counterexample【数论/最大公约数】

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

  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 #275 (Div. 2) A,B,C,D

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

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

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

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

    http://codeforces.com/contest/483/problem/C C. Diverse Permutation time limit per test 1 second memo ...

随机推荐

  1. jQuery 设置图片 src 的2种方法

    // 方法1 $('#imgValidateCode').attr("src", data.CodeUrl); // 方法2 var self = $("#refresh ...

  2. 自定义Mybatis返回类型及注意事项

    一.自定义返回拦截器package com.yaoex.crm.service.util; import org.apache.ibatis.session.ResultContext;import ...

  3. hyperledger fabric 1.0.5 分布式部署 (三)

    本篇博客主要是向读者介绍 fabric 在部署时的一些细节,还有作者自己学习过程中的心得. 初始化相关密钥的程序,实际上是一个shell脚本,并且结构特别简单 generateArtifacts.sh ...

  4. mysql之SQL入门与提升(四)——终结篇,函数

    一.SQL Aggregate (聚合)函数 SQL Aggregate 函数计算从列中取得的值,返回一个单一的值. AVG() - 返回平均值 COUNT() - 返回行数 FIRST() - 返回 ...

  5. 用shell脚本监控MySQL主从同步

    企业面试题1:(生产实战案例):监控MySQL主从同步是否异常,如果异常,则发送短信或者邮件给管理员.提示:如果没主从同步环境,可以用下面文本放到文件里读取来模拟:阶段1:开发一个守护进程脚本每30秒 ...

  6. iOS开发 - 线程与进程的认识与理解

    进程: 进程是指在系统中正在运行的一个应用程序,比如同时打开微信和Xcode,系统会分别启动2个进程; 每个进程之间是独立的,每个进程均运行在其专用且受保护的内存空间内; 线程: 一个进程要想执行任务 ...

  7. RecyclerView notifyDataSetChanged无效问题

    使用notifyDataSetChanged方法更新列表数据时, 一定要保证数据为同个对象(hashCode要一致) 所以重新刷新数据列表时, 不能使用 List list = mlist: 应该使用 ...

  8. mongodb数据库分片实现链接

    http://www.lanceyan.com/tech/arch/mongodb_shard1.html

  9. [题解](树的计数)luogu_P4430猴子打架_/_luogu_P4981父子

    来源:题解 比较不错的博客:http://www.cnblogs.com/dirge/p/5503289.html 最后生成一颗无根树,有n^(n-2)种情况,打架的顺序有(n-1)!种 #inclu ...

  10. CF #541div2 D

    题目本质:形成一个拓扑图,不应带自环. 解决方法: 1.先把等于号的部分用dsu缩点: 2.大于和小于号建立拓扑关系: 3.n*m的矩阵,只要用标号n+j代表m集合的第j个就从二维降到一维了: 4.d ...