Codeforces Round #603 (Div. 2) C.Everyone is A Winner!

tag里有二分,非常的神奇,我用暴力做的,等下去看看二分的题解

但是那个数组的大小是我瞎开的,但是居然没有问题233

#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
const int N = 1e7;
int c[N];
int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        int n;
        scanf("%d", &n);
        int m = sqrt(n) + 1;
        memset(c, 0, sizeof(c));
        int cnt = 0;
        for (int i = 1; i <= m; i++)
            c[cnt++] = n / i;
        while (n >= m) {
            m = n / (n / m) + 1;
            c[cnt++] = n / m;
        }
        printf("%d
", cnt);
        for (int i = cnt - 1; i >= 0; i--)
            printf("%d ", c[i]);
        puts("");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/cminus/p/11963505.html