https://codeforces.com/problemset/problem/762/A
This is a easy problem based on number theory.
We just simply iterate i from 1 to the value of sqrt(n), and check if n is divisble by the value of i and find all of its divisors, then sort them and get the answer.
void solve(){
long long n;
cin >> n;
vector<long long> factors;
for (long long i = 1; i * i <= n; ++i){
if (n % i == 0){
factors.emplace_back(i);
if (i != n / i){
factors.emplace_back(n / i);
}
}
}
sort(factors.begin(), factors.end());
int k;
cin >> k;
cout << (k > factors.size() ? -1ll : factors[k - 1]) << '\n';
}
//what a easy problem..
标签:divisor,factors,long,easy,problem,th From: https://www.cnblogs.com/yxcblogs/p/18061941