Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- #define read() freopen("input.txt", "r", stdin)
- #define write() freopen("output.txt", "w", stdout)
- void mxdiv(ll n)
- {
- ll x = n, mx = -1, cnt =0;
- if(n%2==0){
- cnt++;
- while(n%2==0){
- n/=2;
- }
- }
- for(ll i=3;i*i<=n;i+=2){
- if(n%i==0){
- cnt++;
- mx = max(mx,i);
- while(n%i==0){
- n/=i;
- }
- }
- }
- if(n>1 && n!=x){
- cnt++;
- mx = max(mx,n);
- }
- if(cnt<=1) mx = -1;
- printf("%lld\n",mx);
- }
- int main()
- {
- //read();
- //write();
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- ll n;
- while(1){
- scanf("%lld",&n);
- if(n==0) break;
- if(n<0) n*=-1;
- mxdiv(n);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement