Saleh127

uva 11466.cpp

Jun 27th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define maX 1000008
  6.  
  7. int main()
  8. {
  9.  
  10. ll a,c,d,e,f,i,j,k,l;
  11. while(cin>>a && a)
  12. {
  13. vector<ll>p;
  14. if(a<0) a=a*(-1);
  15. c=a;
  16. for(i=2;i*i<=a;i++)
  17. {
  18. if(c%i==0)
  19. {
  20. while(c%i==0)
  21. {
  22. c/=i;
  23. }
  24. p.push_back(i);
  25. }
  26. }
  27. if(c>1) p.push_back(c);
  28. l=p.size();
  29. if(l<=1) cout<<-1<<endl;
  30. else cout<<p[l-1]<<endl;
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment