题目读懂了一半 一开始以为是每次/2 样例都没过 果然CF不会那么简单
应该是英语阅读能力不好的原因 没有读出题意
题意是 给一个数n
从i开始枚举 将n/i的数字向下取整保存起来 最后顺序输出
我一开始是直接暴力枚举 在第四个text挂了
面对这种跟约数有关系的 要学会使用 i <= sqrt(n)的优化
然后每次枚举的时候 insert(i和n/i) 可以减少枚举的次数
做完这个优化 就过了
**样例中有0记得加入 还有用set来去重
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
int t;
cin >> t;
while(t--)
{
set<int> q;
q.insert(0);
int n;
cin >> n;
for(int i = 1; i*i <= n; i++)
{
q.insert(i);
q.insert(n/i);
}
cout << q.size() << endl;
for(auto it : q) cout << it << " ";
cout << endl;
}
return 0;
}