Advertisement
Ahmed_Negm

Untitled

Aug 28th, 2022
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define nl '\n'
  7. #define sz(x) int(x.size())
  8. #define all(x) x.begin(),x.end()
  9. #define rall(s)  s.rbegin(), s.rend()
  10. #define getline(s) getline(cin>>ws,s)
  11. #define ceill(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  12. #define pi  3.141592653589793
  13.  
  14. /*
  15. ███╗░░██╗███████╗░██████╗░███╗░░░███╗
  16. ████╗░██║██╔════╝██╔════╝░████╗░████║
  17. ██╔██╗██║█████╗░░██║░░██╗░██╔████╔██║
  18. ██║╚████║██╔══╝░░██║░░╚██╗██║╚██╔╝██║
  19. ██║░╚███║███████╗╚██████╔╝██║░╚═╝░██║
  20. ╚═╝░░╚══╝╚══════╝░╚═════╝░╚═╝░░░░░╚═╝
  21.  
  22. */
  23.  
  24. void Fast_IO(){
  25. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  26. // freopen("filename.in", "r", stdin);
  27. // freopen("filename.txt", "w", stdout);
  28. #ifndef ONLINE_JUDGE
  29. freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  30. #endif
  31. }
  32.  
  33.  
  34. set<ll>prime_factors(ll n){
  35.     set<ll>ans;
  36.     while (n%2==0){
  37.         ans.emplace(2);
  38.         n/=2;
  39.     }
  40.     for(int i=3; i< sqrt(n); i++){
  41.         while(n%i==0){
  42.             ans.emplace(i);
  43.             n/=i;
  44.         }
  45.     }
  46.     if(n) ans.emplace(n);
  47.     return ans;
  48. }
  49.  
  50.  
  51.  
  52. void solve(){
  53.   ll n; cin>>n;
  54.   set<ll>st = prime_factors(n);
  55.     ll res =1;
  56.   for(auto&i:st) res*=i;
  57.   cout<<res<<nl;
  58.  
  59.  
  60.  
  61. }
  62.  
  63. int main(){
  64.     Fast_IO();
  65. int t =1;
  66. //cin>>t;
  67. while(t--){
  68. solve();
  69. }
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement