#include #include #include #include using namespace std; int main() { long long C = 0; int M = 0; vector sides; while(true){ cin >> C; cin >> M; sides = vector(M,0); for (int i = 0; i < M; ++i) { int tmp = 0; cin >> tmp; sides[i] = tmp; } if(cin.eof()) { break; } sort(sides.begin(),sides.end()); long long upperBound = sqrt(C); for (size_t i = 0; i < sides.size(); ++i) { if (sides[i] > upperBound) break; long long rest = C % (sides[i]); if (rest != 0) continue; long long potential = C / (sides[i]); auto potentialVecValue = std::lower_bound(sides.begin(), sides.end(), potential); if (potentialVecValue != sides.end() && *potentialVecValue == potential) { std::cout << sides[i] << " " << *potentialVecValue << std::endl; } } } return 0; }