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 ;
}

最新文章

  1. Maven:将Jar安装到本地仓库和Jar上传到私服
  2. “添加到收藏夹”功能(share)
  3. hive中的桶
  4. ExtJs之Ext.util.CSS
  5. iOS 开发中的单例
  6. 关于阿里云ESC上go语言项目编译6l: running gcc failed: Cannot allocate memory
  7. Java开发中的23种设计模式具体解释
  8. Pivot Table系列之展开/折叠用法 (Expand/Collapse)
  9. 云计算的三种服务模式IaaS、PaaS和SaaS的差别
  10. 解决 WordPress“正在执行例行维护,请一分钟后回来”
  11. Docker-----仓库
  12. 实战ELK(8) 安装ElasticSearch中文分词器
  13. SWift中 &#39;?&#39; must be followed by a call, member lookup, or subscript 错误解决方案
  14. Django之Form组件(一)
  15. 2017-2018-2 20155314《网络对抗技术》Exp8 Web基础
  16. Python Signal 信号
  17. GinKgoCTF-Crypto
  18. English trip -- Review Unit2 At school 在学校
  19. C语言数组截取常见问题
  20. Paint、Canvas、Matrix使用解说(一、Paint)

热门文章

  1. window批处理-5 start
  2. Java Management Extensions (JMX) Flume
  3. [翻译]理解Unity的自动内存管理
  4. Mac OS X 开发环境搭建之利用 Parallel Desktop 安装 CentOS 7 [转载]
  5. HDU2089 不要62 —— 数位DP
  6. POJ3660 Cow Contest —— Floyd 传递闭包
  7. jdk8新特性Stream
  8. silverlight DataGrid 内嵌ComboBox 实现加载和保存
  9. bzoj3270博物馆——期望概率DP
  10. linux中vfork对打开文件的处理