ZOJ.2481 Unique Ascending Array【子集】 2015/09/24
来源:互联网 发布:js执行按钮点击事件 编辑:程序博客网 时间:2024/04/30 14:21
Given an array of integers A[N], you are asked to decide the shortest array of integers B[M], such that the following two conditions hold.
- For all integers 0 <= i < N, there exists an integer 0 <= j < M, such that A[i] == B[j]
- For all integers 0 =< i < j < M, we have B[i] < B[j]
Notice that for each array A[] a unique array B[] exists.
Input
The input consists of several test cases. For each test case, an integer N (1 <= N <= 100) is given, followed by N integers A[0], A[1], ..., A[N - 1] in a line. A line containing only a zero indicates the end of input.
Output
For each test case in the input, output the array B in one line. There should be exactly one space between the numbers, and there should be no initial or trailing spaces.
Sample Input
8 1 2 3 4 5 6 7 8
8 8 7 6 5 4 3 2 1
8 1 3 2 3 1 2 3 1
0
Sample Output
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
1 2 3
Author: SHI, Xiaohan
Source: Zhejiang Provincial Programming Contest 2005
求数列中出现过的数值,按升序排列,直接暴力过
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespace std;int main(){ int n,p[110],a[110],i,j,k; while( ~scanf("%d",&n),n ){ k = 0; for( i = 0 ; i < n ; ++i ){ scanf("%d",&p[i]); bool flag = false; for( j = 0 ; j < i ; ++j ){ if( p[i] == p[j] ){ flag = true; break; } } if( !flag ) a[k++] = p[i]; } sort(a,a+k); for( i = 0 ; i < k ; ++i ){ if( i ) printf(" %d",a[i]); else printf("%d",a[i]); } printf("\n"); } return 0;}
- ZOJ.2481 Unique Ascending Array【子集】 2015/09/24
- zoj 2481 Unique Ascending Array
- ZOJ 2481 Unique Ascending Array
- zoj 2481 Unique Ascending Array
- ZOJ 2481 Unique Ascending Array
- ZOJ 2481Unique Ascending Array
- zoj Unique Ascending Array
- zoj 2481 Unique Ascending Array(water still~)
- zoj_2481 Unique Ascending Array
- zoj2481 Unique Ascending Array
- ZOJ2481 Unique Ascending Array
- ZOJ2481-Unique Ascending Array
- ZOJ 2587 Unique Attack
- ZOJ 2587 Unique Attack
- zoj 2587 Unique Attack
- ZOJ-2587-Unique Attack
- array('name', 'unique'),
- zoj 2587(Unique Attack)
- android oom 全解析
- 深入理解Android之设备加密Device Encryption
- 顺时针打印数组
- POJ 2318 TOYS
- gearman消息发送示例
- ZOJ.2481 Unique Ascending Array【子集】 2015/09/24
- 如何查询安卓手机型号以及如何修改型号跟品牌
- 【二维码】:二维码的科普
- 设计模式 - 建造者模式(Builder)
- Codeigniter控制器支持多级目录
- nodejs如何请求路由,http和url模块
- 企业证书打包应用托管到第三方,iPhone4s安装失败。
- getPropertyDescriptors()获取类的属性
- Quartz作业调度框架