Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In the name of Allah.
- // We're nothing and you're everything.
- // Ya Ali!
- /*
- , \ / ,
- / \ )\__/( / \
- / \ (_\ /_) / \
- ____/_____\__\@ @/___/_____\____
- | |\../| |
- | \VV/ |
- | ------___------- |
- |__________Chuta Dragon___________|
- | /\ / \\ \ /\ |
- | / V )) V \ |
- |/ ` // ' \|
- ` V '
- */
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef pair<ll,ll>pll;
- #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
- #define fi first
- #define se second
- #define pb push_back
- ///-------------------------------------------------------------------------------------------------///
- /// KARMA IS LIKE 69,,, YOU GET WHAT YOU GIVE ///
- ///-------------------------------------------------------------------------------------------------///
- void input(ll ara[],ll n)
- {
- for(ll i=0; i<n; i++)
- cin>>ara[i];
- }
- void output(ll ara[],ll n)
- {
- for(ll i=0; i<n; i++)
- cout<<ara[i]<<" ";
- }
- #define eb emplace_back
- const int N=1e7;
- ll k;
- //bitset<N+10>ara;
- ll ara[N+10];
- vector<ll>v;
- void sieve()
- {
- ara[0]=1;
- ara[1]=1;
- v.pb(2);
- int i,j,sz=sqrt(N);
- for(i=2; i<=sz; i++)
- {
- if(ara[i]==0)
- {
- v.push_back(i);
- for(j=i*2; j<=N; j+=i)
- {
- ara[j]=1;
- }
- }
- }
- for(ll i=sz+1; i<=N; i++)
- {
- if(ara[i]==0)
- {
- v.pb(i);
- }
- }
- k=v.size();
- }
- ll prime(ll t)
- {
- if(t<=N)
- {
- if(ara[t]==0)return 1;//prime
- else return 0;// a[0]=1 mana not prime
- }
- else
- {
- ll m=sqrt(t);
- //condi:1(i<k) mana vcetor or full ar modda na takla prime must;
- //condi:1(v[i]<=m) mana vector ar any value jodi sqrt(t) ar boro hala prime must (it is a prime low)
- for(ll i=0;i<k && v[i]<=m;i++)
- {
- if(t%v[i]==0)return 0;
- }
- return 1;
- }
- }
- int main()
- {
- sieve();// suru ta e sieve must (void funtion must call)
- ll n;
- while(cin>>n && n)
- {
- n=abs(n);
- ll mx=-1,cnt=0;
- ll len=sqrt(n);
- for(ll i=2;i<=len;i++)
- {
- if(n%i==0)
- {
- if(prime(i))
- {
- cnt++;
- mx=max(i,mx);
- }
- if(prime(n/i) && n/i!=i)//n/i!=9 must coz 9=3,3
- {
- cnt++;
- mx=max(n/i,mx);
- }
- }
- }
- if(cnt<2)cout<<-1<<endl;
- else cout<<mx<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement