Description

You are developing a new feature for the website which sells airline tickets: being able to sort tickets by price! You have already extracted the tickets' prices, so there's just the last step to be done...

You are given an array of integers. Sort it in non-descending order.

Input

The input consists of a single line of space-separated integers. The first number is n (1 ≤ n ≤ 10) — the size of the array. The following nnumbers are the elements of the array (1 ≤ ai ≤ 100).

Output

Output space-separated elements of the sorted array.

Example
input
3 3 1 2
output
1 2 3 
Note

Remember, this is a very important feature, and you have to make sure the customers appreciate it!

排序。不过必须运行时间超过1s,不会怎么控制时间?有个好办法,随便找个代码,反正要运行1s以上的,加进去,然后输出结果就好了,这里我用了网络赛的代码

 #include<bits/stdc++.h>
using namespace std; #define MAXN 100
#define MAXM 10001
#define MAXP 266666
#define MAX 3200001
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl
#define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))
#define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))
#define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2)) namespace pcf
{
long long dp[MAXN][MAXM];
unsigned int ar[(MAX >> ) + ] = {};
int len = , primes[MAXP], counter[MAX]; void Sieve()
{
setbit(ar, ), setbit(ar, );
for (int i = ; (i * i) < MAX; i++, i++)
{
if (!chkbit(ar, i))
{
int k = i << ;
for (int j = (i * i); j < MAX; j += k) setbit(ar, j);
}
} for (int i = ; i < MAX; i++)
{
counter[i] = counter[i - ];
if (isprime(i)) primes[len++] = i, counter[i]++;
}
} void init()
{
Sieve();
for (int n = ; n < MAXN; n++)
{
for (int m = ; m < MAXM; m++)
{
if (!n) dp[n][m] = m;
else dp[n][m] = dp[n - ][m] - dp[n - ][m / primes[n - ]];
}
}
} long long phi(long long m, int n)
{
if (n == ) return m;
if (primes[n - ] >= m) return ;
if (m < MAXM && n < MAXN) return dp[n][m];
return phi(m, n - ) - phi(m / primes[n - ], n - );
} long long Lehmer(long long m)
{
if (m < MAX) return counter[m]; long long w, res = ;
int i, a, s, c, x, y;
s = sqrt(0.9 + m), y = c = cbrt(0.9 + m);
a = counter[y], res = phi(m, a) + a - ;
for (i = a; primes[i] <= s; i++) res = res - Lehmer(m / primes[i]) + Lehmer(primes[i]) - ;
return res;
}
} long long solve(long long n)
{
int i, j, k, l;
long long x, y, res = ; /*for (i = 0; i < pcf::len; i++){
printf("%I64d\n",pcf::Lehmer(n));
x = pcf::primes[i], y = n / x;
if ((x * x) > n) break;
res += (pcf::Lehmer(y) - pcf::Lehmer(x));
} for (i = 0; i < pcf::len; i++){
x = pcf::primes[i];
if ((x * x * x) > n) break;
res++;
}*/
res=pcf::Lehmer(n);
return res;
}
int xx[];
int main()
{
pcf::init();
long long n, res;
while(cin>>n)
{
int x=solve();
for(int i=; i<=n; i++)
{
cin>>xx[i];
}
sort(xx+,xx+n+);
for(int i=; i<=n; i++)
{
cout<<xx[i]<<" ";
}
}
return ;
}

April Fools Contest 2017 F的更多相关文章

  1. April Fools Contest 2017 题解&源码(A,数学 B,数学 C,数学 D,字符串 E,数字逻辑 F,排序,卡时间,G,数学)

    A. Numbers Joke time limit per test:2 seconds memory limit per test:64 megabytes input:standard inpu ...

  2. April Fools Contest 2017 题解

    趁着上课无聊,来补一补-- A. Numbers Joke 直接oeis就好了:http://oeis.org/search?q=numbers+joke&language=english&a ...

  3. Codeforces April Fools Contest 2017

    都是神题,我一题都不会,全程听学长题解打代码,我代码巨丑就不贴了 题解见巨神博客 假装自己没有做过这套

  4. April Fools Contest 2017 E

    Description Input The input consists of four lines, each line containing a single digit 0 or 1. Outp ...

  5. April Fools Contest 2017 D

    Description Input The only line of the input contains a string of digits. The length of the string i ...

  6. April Fools Contest 2017 C

    Description DO YOU EXPECT ME TO FIND THIS OUT? WHAT BASE AND/XOR LANGUAGE INCLUDES string? DON'T BYT ...

  7. April Fools Contest 2017 B

    Description Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it? Input The i ...

  8. April Fools Contest 2017 A

    Description Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer ...

  9. April Fools Contest 2018

    这个比赛不正经,但是我可以一本正经的写代码啊 A. Quirky Quantifiers time limit per test 2 seconds memory limit per test 64 ...

随机推荐

  1. Python 学习资料分享

    有同学需要学习 Python,确实,随着人工智能被炒的火热,再加上大数据时代,作为程序员的我们,怎么可能坐得住,必须尝尝鲜,给自己增加一项技能,增加自己的竞争了. 内容定位 这方面的学习资料比较多,本 ...

  2. exists用在linq上

    SQL里面,有时候会用到exists或者not exists. select * from yb t1 where not exists(select 1 from yb t2 where trunc ...

  3. sanic官方文档解析之streaming(流动,滚动)和class_based_views(CBV的写法)

    1,streaming(流媒体) 1.1请求流媒体 Sanic允许你通过流媒体携带请求数据,如下,当请求结束await request.stream.read()就会返回None,仅仅只有post请求 ...

  4. 使用JavaScript获取浏览器Chrome版本信息

    Navigator对象包含了有关浏览器的信息 可通过访问其属性appVersion或userAgent来获取浏览器Chrome版本 例如,我所使用的QQ浏览器的appVersion和userAgent ...

  5. VC FTP服务器程序分析(三)

    CControlSocket类的分析,CControlSocket类的内容比较多,为什么呢.因为通信控制命令的传输全部在这里,通信协议的多样也导致了协议解析的多样. 1.OnReceive  其大致说 ...

  6. 关于div li 等标签之间自带间距

    可以用float来清除标签之间的间距. ps :ul使用font-size:0 唯一的缺点就是要再次设置LI的font-size

  7. Hadoop中序列化与Writable接口

    学习笔记,整理自<Hadoop权威指南 第3版> 一.序列化 序列化:序列化是将 内存 中的结构化数据 转化为 能在网络上传输 或 磁盘中进行永久保存的二进制流的过程:反序列化:序列化的逆 ...

  8. Java面试必会知识点

    1.== 和 equals()比较: (1)== 是运算符,equals()是Object中定义的方法: (2)== 比较的是 数值 是否相同,基本类型比较数值,引用类型比较对象地址的数值:且变量类型 ...

  9. linux 设备驱动程序中的一些关联性思考

    首先,个人感觉设备驱动程序与应用程序中的文件操作隔得有点远,用户空间不论是直接使用系统调用还是库函数都是通过系统调用的接口进入内核空间代码的.但是看过一个博客的分析整个过程,感觉中间层太过麻烦,必须经 ...

  10. classname.this 和 this的使用场景

    今天在写代码时,发现在写了一个内部类,而在内部类中需要调用外部类的实例方法,直接使用this调用发现调用的不是外部类而是内部类,于是查找资料原来需要使用外部类的classname.this这样的调用, ...