fork download
  1. #include <iostream>
  2. #include <unordered_set>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. long long n;
  9. int k;
  10. cin >> n >> k;
  11. int sqrt_n = sqrt(n);
  12. unordered_set<int> remainders;
  13. for (int i = 1; i <= min(k, sqrt_n); ++i) {
  14. int remainder = n % i;
  15.  
  16. if (remainders.find(remainder) != remainders.end()) {
  17. cout << "No" << endl;
  18. return 0;
  19. }
  20. remainders.insert(remainder);
  21. }
  22. if (k > sqrt_n) {
  23. for (int i = sqrt_n + 1; i <= k; ++i) {
  24. int remainder = n % i;
  25.  
  26. if (remainders.find(remainder) != remainders.end()) {
  27. cout << "No" << endl;
  28. return 0;
  29. }
  30. remainders.insert(remainder);
  31. }
  32. }
  33. cout << "Yes" << endl;
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0.01s 5220KB
stdin
Standard input is empty
stdout
Yes