Educational Codeforces Round 92 (Rated for Div. 2) A.LCM Problem(思维)

题目传送
题意:
给你 l,r,让你求俩个数l <= x < y <= r ,并且l <= Lcm(x,y) <= r,

思路:
既然1求一个满足的,那么我们只用使得求出来的Lcm是最小的即可,最小为多少呢?就是 l 和 2l,如果r < 2l,那么就不成立

AC代码

#include 
inline long long read(){char c = getchar();long long x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 2e6 + 5;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);
    int t;
    cin >> t;
    while(t--)
    {
        ll l,r;
        cin >> l >> r;
        l*2 <= r ? cout << l << " " << l*2 << endl : cout << -1 << " " << -1 << endl;
    }
}

你可能感兴趣的:(codeforces,思维)