Codeforces 1285C. Fadi and LCM Solution


///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd Batch
///Islamic University,Bangladesh
#include <iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    {
        long long int  n,a,f,i,b,lcm,gcd;
        cin>>n;
        for(i=sqrt(n); i>=1; i--)
        {
            if(n%i==0)
            {
                gcd=__gcd(n/i,i);
                lcm=(n/i)*i/gcd;
                if(lcm==n)
                {
                    cout<<i<<" "<<n/i<<endl;
                    f=1;
                    break;
                }
                if(f==1)
                break;
            }
        if(f==1)
                break;
        }
    }
}

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.