Duplicate Removal
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 1745   Accepted: 1213

Description

The company Al's Chocolate Mangos has a web site where visitors can guess how many chocolate covered mangos are in a virtual jar. Visitors type in a guess between 1 and 99 and then click on a "Submit" button. Unfortunately, the response time from the server
is often long, and visitors get impatient and click "Submit" several times in a row. This generates many duplicate requests. 

Your task is to write a program to assist the staff at ACM in filtering out these duplicate requests.

Input

The input consists of a series of lines, one for each web session. The first integer on a line is N, 0 < N ≤ 25, which is the number of guesses on this line. These guesses are all between 1 and 99, inclusive. The value N = 0 indicates the end of all the input.

Output

For each input data set, output a single line with the guesses in the original order, but with consecutive duplicates removed. Conclude each output line with the dollar sign character '$'. Note that there is a single space between the last integer and the dollar
sign.

Sample Input

5 1 22 22 22 3
4 98 76 20 76
6 19 19 35 86 86 86
1 7
0

Sample Output

1 22 3 $
98 76 20 76 $
19 35 86 $
7 $

题意是将相近的重复元素删除。

代码:

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <set>
#pragma warning(disable:4996)
using namespace std; vector<int>a;
int num; int main()
{
int i,temp;
while(cin>>num)
{
if(num==0)
break;
a.clear();
for(i=1;i<=num;i++)
{
cin>>temp;
a.push_back(temp);
} vector<int>::iterator iter =unique(a.begin(),a.end());
a.erase(iter,a.end());
for(i=0;i<a.size();i++)
{
cout<<a[i]<<" ";
}
cout<<"$"<<endl;
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

POJ 3916:Duplicate Removal 将相近的重复元素删除的更多相关文章

  1. poj 1743 Musical Theme(最长重复子串 后缀数组)

    poj 1743 Musical Theme(最长重复子串 后缀数组) 有N(1 <= N <=20000)个音符的序列来表示一首乐曲,每个音符都是1..88范围内的整数,现在要找一个重复 ...

  2. 大型网站技术架构(四)--核心架构要素 开启mac上印象笔记的代码块 大型网站技术架构(三)--架构模式 JDK8 stream toMap() java.lang.IllegalStateException: Duplicate key异常解决(key重复)

    大型网站技术架构(四)--核心架构要素   作者:13GitHub:https://github.com/ZHENFENG13版权声明:本文为原创文章,未经允许不得转载.此篇已收录至<大型网站技 ...

  3. [LeetCode] 217. Contains Duplicate 包含重复元素

    Given an array of integers, find if the array contains any duplicates. Your function should return t ...

  4. [LeetCode] 219. Contains Duplicate II 包含重复元素 II

    Given an array of integers and an integer k, find out whether there are two distinct indices i and j ...

  5. [LeetCode] 220. Contains Duplicate III 包含重复元素 III

    Given an array of integers, find out whether there are two distinct indices i and j in the array suc ...

  6. [Swift]LeetCode217. 存在重复元素 | Contains Duplicate

    Given an array of integers, find if the array contains any duplicates. Your function should return t ...

  7. leetcode-219-Contains Duplicate II(使用set来判断长度为k+1的闭区间中有没有重复元素)

    题目描述: Given an array of integers and an integer k, find out whether there are two distinct indices i ...

  8. leetcode-217-Contains Duplicate(使用排序来判断整个数组有没有重复元素)

    题目描述: Given an array of integers, find if the array contains any duplicates. Your function should re ...

  9. LeetCode 217:存在重复元素 Contains Duplicate

    题目: 给定一个整数数组,判断是否存在重复元素. Given an array of integers, find if the array contains any duplicates. 如果任何 ...

随机推荐

  1. 数学公式在 iOS 中的表示

    1. 三角函数  double sin (double);正弦  double cos (double);余弦  double tan (double);正切 2 .反三角函数  double asi ...

  2. vs code 本地调试配置

    { "name": "使用本机 Chrome 调试", "type": "chrome", "request& ...

  3. MD5摘要

    MD5简介 MD5即Message-Digest Algorithm 5(信息-摘要算法),属于摘要算法,是一个不可逆过程,就是无论多大数据,经过算法运算后都是生成固定长度的数据,结果使用16进制进行 ...

  4. linux安装jdk并设置环境变量(看这一篇文章即可)

    1.查看linux位数 查看linux是32位还是64位,影响需要下载JDK的版本   系统位数 jdk位数 x86(32位) 32位 x86_64(64位) 32位 64位 在linux命令输入: ...

  5. js加密(九)hr.bibibi md5

    1. 寻找加密js: 2. 结果: 3. execjs调用js即可.

  6. 笔记||Pyhton3进阶之多线程原理

    # 多线程 # 一个进程相当于一个或多个线程 # 当没有多线程编程时,一个进程也是一个主线程 # 但有多线程编程时,一个进程包含多个线程,包括主线程 # 使用线程 可以实现程序的并发 # python ...

  7. java猜拳

    import java.util.Scanner; public class startGuess { Person jia; Computer yi; int count; public void ...

  8. QQ企业通--客户端登陆模块设计---知识点2

    Maximizable 属性               获取一个值,该值指定窗口是否可以最大化. fromBorderstyle 成员名称    说明 None            无边框. Fi ...

  9. 新闻网大数据实时分析可视化系统项目——13、Cloudera HUE大数据可视化分析

    1.Hue 概述及版本下载 1)概述 Hue是一个开源的Apache Hadoop UI系统,最早是由Cloudera Desktop演化而来,由Cloudera贡献给开源社区,它是基于Python ...

  10. springboot,dubbo,nacos,spring-cloud-alibaba的整合

    最近,自去年阿里开源了dubbo2.7及一系列产品后,阿里也打造了融入spring-cloud 的生态体系,本人关注,今年阿里开源的的spring-cloud-alibaba基本孵化完成,笔者更是对这 ...