lina_os

Untitled

May 6th, 2025 (edited)
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4.  
  5. using namespace std;
  6.  
  7. vector<ll> sieve(ll n){
  8.     vector <bool> isPrime(n + 1, 1);
  9.     isPrime[0] = isPrime[1] = 0;
  10.  
  11.     for(ll i = 2; i * i <= n; i++){
  12.         if(isPrime[i]){
  13.             for(ll j = i * i; j <= n; j += i)
  14.                 isPrime[j] = false;
  15.         }
  16.     }
  17.     vector<ll>v;
  18.     for(ll i = 2; i < n + 1; i++){
  19.         if(isPrime[i]) v.push_back(i*i);
  20.     }
  21.  
  22.     return v;
  23. }
  24.  
  25. int main() {
  26.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  27.     ll n;
  28.     cin >> n;
  29.     map<ll,ll>m;
  30.     ll xx=n;
  31.     for (ll i=2; i*i<=xx; i++) {
  32.         while (n%i==0) {
  33.             m[i]++;
  34.             n/=i;
  35.         }
  36.         if (n==1) break;
  37.     }
  38.     if (n!=1) m[n]++;
  39.     if (m.empty()||m.size()==1 && m.begin()->second==1) {
  40.         cout << 1 << endl << 0;
  41.         return 0;
  42.     }
  43.     ll all=0;
  44.     for (auto x:m) {
  45.         all+=x.second;
  46.     }
  47. //    cout << all << endl;
  48.     if (all==2) cout << 2 << endl;
  49.     else {
  50.         cout << 1 << endl;
  51.  
  52.         if (m.size()>1) cout << (m.begin()->first) * ((++m.begin())->first);
  53.         else cout << (m.begin()->first) * (m.begin()->first);
  54.     }
  55.     return 0;
  56. }
  57.  
  58. /*
  59.  */
Advertisement
Add Comment
Please, Sign In to add comment