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 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

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

Powered by Blogger.