#include using namespace std; vector nums; // 求所有约数 void get_divisors(int x) { for (int i = 1; i <= x / i; i++) // 枚举到sqrt即可 if (x % i == 0) { nums.push_back(i); if (i != x / i) nums.push_back(x / i); // 如果 i==x/i 只存储一个,比如 5*5=25 } sort(nums.begin(), nums.end()); // 排序输出 } int main() { int n; cin >> n; while (n--) { int x; cin >> x; nums.clear(); get_divisors(x); for (auto c : nums) printf("%d ", c); puts(""); } return 0; }