fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  6.  
  7. int n, k;
  8. cin >> n >> k;
  9. int count = 0;
  10. for (int i = 1; i <= n; i++) {
  11. if (n % i == 0) {
  12. count++;
  13. if (count == k) {
  14. cout << i << "\n";
  15. return 0;
  16. }
  17. }
  18. }
  19. cout << -1 << "\n";
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
-1