码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2019-11-30 19:34:37      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:eof   while   tag   二分   pre   const   bsp   mes   没有   

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\n", cnt);
        for (int i = cnt - 1; i >= 0; i--)
            printf("%d ", c[i]);
        puts("");
    }
    return 0;
}

 

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

标签:eof   while   tag   二分   pre   const   bsp   mes   没有   

原文地址:https://www.cnblogs.com/cminus/p/11963505.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!