首頁 > web前端 > html教學 > Codeforces Round #275 (Div. 2)A Countexample_html/css_WEB-ITnose

Codeforces Round #275 (Div. 2)A Countexample_html/css_WEB-ITnose

WBOY
發布: 2016-06-24 11:55:32
原創
947 人瀏覽過

题目链接:Counterexample



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?

More specifically, you need to find three numbers (a,?b,?c), such that l?≤?a?

Input

The single line contains two positive space-separated integers l, r (1?≤?l?≤?r?≤?1018; r?-?l?≤?50).

Output

Print three positive space-separated integers a, b, c ? 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.






大致题意:给定l和r,找出满足条件 l?≤?a?


解题思路:暴力枚举。枚举所有的情况,对每个情况进行判断。这种做法的前提是数据不大,数据要是大了,就不能这么直接暴力了。





AC代码:

#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;#define INF 0x7fffffff#define LL long longLL gcd(LL a, LL b){    if(!b) return a;    return gcd(b, a%b);}int main(){    #ifdef sxk        freopen("in.txt","r",stdin);    #endif    LL l,r,a,b,c;    while(scanf("%lld%lld",&l,&r)!=EOF)    {        int flag = 0;        for(LL i=l; i  <br>  <br>  <p></p>  <p><br> </p>  <p><br> </p>  <p><br> </p> </time.h></stdlib.h></math.h></string></map></set></queue></vector></algorithm></iostream></string.h></stdio.h>
登入後複製
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板