Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

### souvikmahato's blog

By souvikmahato, history, 4 weeks ago, ,

Here , is a very simple algorithm to the above problem in O(1).

if x=1, then no solution exists , thus print -1. else for any x , print a=x , b=x . u can see it satisfies all the condition :- 1) a%b=0: x%x=0, 2)a.b > x : x.x >x , 3)a/b < x : x/x <x .

Hope u get this solution and can easily solve the problem.

here is my solution:-

#include<bits/stdc++.h>
using namespace std;

int main()
{
int x;
cin>>x;
if(x==1)
{
cout<<-1;
return 0;
}
else
{
cout<<x<<" "<<x;
}
}

• -20

 » 4 weeks ago, # |   0 Auto comment: topic has been updated by souvikmahato (previous revision, new revision, compare).
 » 4 weeks ago, # |   0 Auto comment: topic has been updated by souvikmahato (previous revision, new revision, compare).
 » 4 weeks ago, # |   +13 Wow! Thanks! I can't solve this problem for an year! You are the best!
 » 4 weeks ago, # | ← Rev. 2 →   +13 Wow, how you arrived with this? Please also add your though process.
 » 4 weeks ago, # | ← Rev. 2 →   0 In the third condition it is a/b < x not a/b > x. I think it was a typo.
•  » » 4 weeks ago, # ^ |   0 yeah that was typo sorry for that