(找了很多题解都是找规律,但是我觉得规律并不好找啊)
(当n只有1个质因数,答案为这个质因数,这个很显然)
(当n多于两个质因数,随便取其中两个x,y)
(gcd(x,y)=1)
(由于从1出发,每次可以前进x,y格,也可以后退x,y格)
(所以从1能到的地方是ax+by=c)
(而gcd(a,b)=1,根据裴蜀定理,c为gcd(a,b)的倍数)
(所以可以去任意一格,也就是任意一个格子颜色相同)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6;
ll vis[maxn+10],prime[maxn],tot;
vector<ll>vec;
int main()
{
make_prime();
ll n,temp=0;
cin>>n;
for(ll i=2;i*i<=n;i++)
{
if(n%i==0)
{
vec.push_back(i);
while(n%i==0) n/=i;
}
}
if(n!=1) vec.push_back(n);
temp=vec.size();
if(temp>1) cout<<1;
else if(temp==1) cout<<vec[0];
else if(temp==0) cout<<n;
}