Everyone is a Winner!
Posted karshey
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Everyone is a Winner!相关的知识,希望对你有一定的参考价值。
输入:
4
5
11
1
3
输出:
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3
注意:
第一次做的时候超时了,实际上从1-sqrt(n)就够了。
观察样例可知:
a.ins(i);a.ins(x/i);
为了防重复,用set集合。插入用insert。
输出是从小到大的,set会自动从小到大排序!
#include<bits/stdc++.h>
#define ins insert
using namespace std;
int main()
{
int n;cin>>n;
while(n--)
{
int x;cin>>x;
set<int>a;
a.ins(0);
a.ins(1);
int m=sqrt(x);
for(int i=m;i>=1;i--)
{
a.ins(i);
a.ins(x/i);
}
cout<<a.size()<<endl;
for(auto i:a)
{
cout<<i<<" ";
}
cout<<endl;
}
return 0;
}
以上是关于Everyone is a Winner!的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #603 (Div. 2) C. Everyone is a Winner! (数学)
Codeforces Round #603 (Div. 2) C.Everyone is A Winner!
Gym 100712A - Who Is The Winner
Gym 100952 A. Who is the winner?
CodeForces-2015 HIAST Collegiate Programming Contest-Gym-100952A-Who is the winner?
Gym 100952A&&2015 HIAST Collegiate Programming Contest A. Who is the winner?字符串,暴力