思路:
浅推一波我们发现就是把2n分成一个奇数*偶数,我们只需要把2的质因子全部除掉,然后把剩下的分解质因数
c o d e code code
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
unsigned ll n;
int main() {
cin>>n;
if(n <= 2) { printf("-1"); return 0; }
n *= 2;
unsigned ll k = 1;
while(n % 2 == 0) {
n /= 2;
k *= 2;
}
if(n == 1) {
printf("-1");
return 0;
}
for(unsigned ll i = 3; i * i <= n; i ++) {
if(n % i == 0) {
cout<<min(i, (k < n ? k : n));
return 0;
}
}
cout<<(k < n ? k : n);
return 0;
}