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

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 &g...

Powered by Blogger.