Codeforces 1294C. Product of Three Numbers Solution

  1. ///**********ALLAH IS ALMIGHTY************///
  2. ///AH Tonmoy
  3. ///Department of CSE,23rd Batch
  4. ///Islamic University,Bangladesh
  5. #include<iostream>
  6. using namespace std;
  7. int main()
  8. {
  9. long long int n,ar[10],i,v=0,t;
  10. cin>>t;
  11. while(t--)
  12. {
  13. v=0;
  14. cin>>n;
  15. for(i=2; i*i<n&&v<2; i++)
  16. {
  17. if(n%i==0)
  18. {
  19. ar[v++]=i;
  20. n=n/i;
  21. }
  22. }
  23. if(v!=2)
  24. {
  25. cout<<"NO"<<endl;
  26. }
  27.  
  28. else
  29. {
  30. cout<<"YES"<<endl;
  31. cout<<ar[0]<<" "<<ar[1]<<" "<<n<<endl;
  32. }
  33.  
  34. }
  35. }

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.