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. mysql insert操作

    insert的语法 INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [(col_name,...)] ...

  2. linux内核模块依赖图

    Module                  Size  Used by btrfs                 880032  0 raid6_pq               97812  ...

  3. 区分虚拟机和machine simulator

    1 虚拟机和machine simulator的不同 虚拟机是让多个操作系统同时共用现有的硬件架构,它不会模拟新的硬件架构.qemu这样的模拟器是模拟新的硬件架构,这个架构和host不同.

  4. Get Luffy Out (poj 2723 二分+2-SAT)

    Language: Default Get Luffy Out Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7969   ...

  5. jdbc navcat for mysql 连不上远程服务器的原因(安全组设置)

    如果你权限,防火墙什么都设置好了,但是还是连不上远程数据库, 那么你就必须要看看你的服务器上安全组的设置(很重要) 这里以阿里云为例子(之前用阿里云服务都没设置),现在阿里云的服务器租的时候就要求配置 ...

  6. fullcalendar小结

    最近做的项目需要一个日程插件,在网上找了一些插件觉的fullcalendar 比较好用,总结一下以备后用. 效果图如下: var calendar = null; function ShowCalen ...

  7. Servlet的HelloWorld

    设置好TOMCAT环境变量(如何设置?)后在命令行输入startup可以启动Tomcat,输入shutdown可以关闭Tomcat. /WEB-INF/web.xml是称为部署描述器的配置文件,Jav ...

  8. SPOJ:PATHETIC STRINGS(分配问题&贪心)

    Problem statement: A string is said to be “PATHETIC” if all the characters in it are repeated the sa ...

  9. 洛谷 P3957 跳房子 —— 二分答案+单调队列优化DP

    题目:https://www.luogu.org/problemnew/show/P3957 先二分一个 g,然后判断: 由于转移的范围是一个区间,也就是滑动窗口,所以单调队列优化: 可以先令队尾为 ...

  10. jmeter+jenkins+ant部署持续集成测试

    原文地址:http://blog.csdn.net/kaluman/article/details/74535495 开头的注意事项: 1.所有的环境变量和代码,都需要使用英文的符号,变量之间都需要英 ...