求救,这是哪里有问题
查看原帖
求救,这是哪里有问题
1098609
bladeABC楼主2023/11/1 15:45
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int fun(int x){
        for(int i=2;i*i<=x;i++){
            if(x%i==0)return i;
        }
        return -1;
    }
void solve(){
        int l,r;
        cin>>l>>r;
        if(r<=3){
            cout<<-1<<endl;
        return ;
        }
        if(l<r){
            if(r%2!=0)r--;
                cout<<r/2<<" "<<r/2<<endl;
        }
        else{
                int x=fun(l);
                if(x==-1)cout<<-1<<endl;
        else
                 cout<<x<<" "<<x*(1/x-1)<<endl;
        }
    }
signed main(){
int t;
cin>>t;
while(t--){
        solve();
    }
}
2023/11/1 15:45
加载中...