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

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.