C. Tile Painting

http://codeforces.com/contest/1243/problem/C

#include <bits/stdc++.h>
//#include <queue>
//#include <cmath>
//#include <iostream>
//#include <unordered_map>

#define lson rt<<1
#define rson rt<<1|1
#define lowbit(x) ((x)&(-x))
#define mem(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define INF 0x3f3f3f3f
#define ll long long
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

const int mod=1e9+7;
const int N=1e5+9;


int main()
{
    FAST_IO;
    //freopen("input.txt","r",stdin);

    ll n;
    cin>>n;

    ll k=sqrt(n);
    int cnt=0;
    int ans=0;
    for(int i=2;i<=k;i++)
    {
        if(n%i==0)
        {
            ans=i;
            cnt++;
            while(n%i==0) n/=i;
            if(n>1) cnt++;
            if(cnt>1) break;
        }
    }
    if(cnt>1)
    {
        cout<<1<<endl;
    }
    else if(cnt==1)
    {
        cout<<ans<<endl;
    }
    else
    {
        cout<<n<<endl;
    }


    return 0;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章