/* -*- coding: utf-8 -*- * * 136.cc: No.136 Yet Another GCD Problem - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ /* typedef */ typedef vector vi; /* global variables */ /* subroutines */ /* main */ int main() { int n, k; cin >> n >> k; vi fs; for (int i = 1; i * i <= n; i++) if (n % i == 0) { fs.push_back(i); int j = n / i; if (j != i) fs.push_back(j); } sort(fs.begin(), fs.end()); //for (int i = 0; i < fs.size(); i++) printf("%d ", fs[i]); putchar('\n'); int maxd = 0; for (int i = 2; i <= k; i++) { int d = n / i; if (d == 0) break; vi::iterator vit = upper_bound(fs.begin(), fs.end(), n / i) - 1; if (maxd < *vit) maxd = *vit; } printf("%d\n", maxd); return 0; }