A. Counterexample (Codeforces Round #275(div2)

限时加码!20+主流AI编程工具免费用 购周边加赠Coding Plan Lite,Claude Code、Cursor等即刻畅享,学习进阶更高效! 阅读详情
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 ≤ 1018r - 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.

找出3个数,前两个的最大公约数为1,后两个最大公约数为1,第1个和第3个的最大公约数不为1.

由于题目中说了,r-l<=50,可以直接O(n^3)暴力做。

代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
long long gcd(long long a,long long b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
    long long l,r;
    long long x,y,z;
    int sign=0;
    scanf("%I64d%I64d",&l,&r);
    for(long long i=l;i<=r;i++)
    {
        for(long long j=i+1;j<=r;j++)
        {
            for(long long k=j+1;k<=r;k++)
            {
                if(gcd(i,j)==1&&gcd(j,k)==1&&gcd(i,k)!=1)
                {
                    x=i;
                    y=j;
                    z=k;
                    sign=1;
                    break;
                }
            }
            if(sign)
            break;
        }
        if(sign)
        break;
    }
    if(sign)
    printf("%I64d %I64d %I64d\n",x,y,z);
    else
    printf("-1\n");
    return 0;
}


keil4.72添加GD32F10x芯片 1. 下载 GD32F10x_AddOn_V2.0.1.rar,解压缩。 2. 安装 运行GigaDevice.GD32F10x_AddOn.2.0.0.exe 安装位置 再新建工程,发现已经有GD32F10x 3. 增加的文件分析 运行GigaDevice.GD32F10x_AddOn.2.0.0.exe后,在keil文件夹种增加文件如下: ... 阅读详情

相关推荐

六轴机器人正解

采用的是John H.Craig在【机器人学导论】中的改进DH模型 1.六轴坐标系 2.DH参数 i αi−1\alpha_{i-1}αi−1​ ai−1a_{i-1}ai−1​ did_idi​ θi\theta_iθi​初值 1 0 0 0 0 2 -90 a1a_1a1​ 0 -90 3 0 a2a_2a2​ 0 -90 4 -90 a3a_3a3​ d4d...

m0_37581770的博客 2491

A. Counterexample

解题说明:此题是要求(a,b),(b,c)最大公约数都为1,但是(a,c)最大gongyue

无知的我 1662

学术版GPT安装教程——保姆版(附带原生GPT注册教程)

学术版GPT图文安装教程

DBenD的博客 2万+

Counterexample(gcd练习题)CodeForces - 483A

题目描述: 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

qq_48627750的博客 289

CF#275 (Div. 2) A.(暴力)

A. Counterexample time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output 题目链接:http://codeforces.com/contest/483/problem/A

代码艺术的道与术 1939

Codeforces-275a D Lights Out

Lights Out time limit per test 2 seconds memory limit per test 256 megabytes Lenny is playing a game on a 3 × 3 grid of lights. In the beginning of the game all lights are switched on. Pr

JSure的代码库 1656

Codeforces Round #275 (Div. 2) D. Interesting Array

题意:n个数,m组询问,每组询问l

黑山老猴妖的专栏 779

Codeforces Round #275 (Div. 2) A Counterexample

A Counterexample

gwq5210的专栏 850

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

http://codeforces.com/contest/483/problem/AA. Counterexampletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour friend has recently learned about ...

weixin_30563917的博客 108

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

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 num...

weixin_30677617的博客 62

Codeforces Round #275 (Div. 2)

占坑

CHEATBEATER 1110

Codeforces Round #275

Codeforces Round #275

Muti-Agent 2556

Codeforces Round #275 (Div. 2) Counterexample

题目叙述:易于理解。 解题思路:暴力循环 1.数据过大,用long long int 2.求互质时用辗转相除法 我的代码: #include #include using namespace std; long long int gcd(long long int m,long long int n) { if(!(m%n)) return n;

u013844639的专栏 402

Codeforces Round #275 (Div. 2) D

D. Interesting Array

A Cube Master 480

『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]-CodeForces 237C,素数打表,二分查找...

C. Primes on Interval time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You've decided to carry out a survey in the theory of ...

weixin_30260399的博客 162

线段树(good)Codeforces Round #275 (Div. 2)D

题意: 构造一个序列,满足m个形如:[l,r,c] 的条件。 [l,r,c]表示[l,r]中的元素按位与(&)的和为c。 解法: 线段树维护,sum[rt]表示要满足到现在为止的条件时该子树的按位与和至少为多少。 更新时,如果val的pos位为1,那么整个区间的按位与和pos位也应该为1,否则与出来就不对了。(这是本题解题的核心) 那么此时更新 sum[rt] |= val 即可。然后再ch

龙崎的专栏 601

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

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 numb

Alex 1330

Code forces 275C-----思维---二分

k-Multiple Free Set Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 274A Description A k-multiple free set is a set

blue_hpu的博客 374
上一篇: E. Riding in a Lift(Codeforces Round #274)
下一篇: B. Friends and Presents(Codeforces Round #275(div2)
AC_way
博客等级 码龄12年 55粉丝 248原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值