POJ 3916:Duplicate Removal 将相近的重复元素删除
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 1745 | Accepted: 1213 |
Description
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
Output
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 将相近的重复元素删除的更多相关文章
- poj 1743 Musical Theme(最长重复子串 后缀数组)
poj 1743 Musical Theme(最长重复子串 后缀数组) 有N(1 <= N <=20000)个音符的序列来表示一首乐曲,每个音符都是1..88范围内的整数,现在要找一个重复 ...
- 大型网站技术架构(四)--核心架构要素 开启mac上印象笔记的代码块 大型网站技术架构(三)--架构模式 JDK8 stream toMap() java.lang.IllegalStateException: Duplicate key异常解决(key重复)
大型网站技术架构(四)--核心架构要素 作者:13GitHub:https://github.com/ZHENFENG13版权声明:本文为原创文章,未经允许不得转载.此篇已收录至<大型网站技 ...
- [LeetCode] 217. Contains Duplicate 包含重复元素
Given an array of integers, find if the array contains any duplicates. Your function should return t ...
- [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 ...
- [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 ...
- [Swift]LeetCode217. 存在重复元素 | Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return t ...
- 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 ...
- leetcode-217-Contains Duplicate(使用排序来判断整个数组有没有重复元素)
题目描述: Given an array of integers, find if the array contains any duplicates. Your function should re ...
- LeetCode 217:存在重复元素 Contains Duplicate
题目: 给定一个整数数组,判断是否存在重复元素. Given an array of integers, find if the array contains any duplicates. 如果任何 ...
随机推荐
- freemarker 作为 word 模板实现下载功能
1:新建一个.doc 文档写好自己要导出文字如下图 2:把word 文档另存为xml 格式的文件用编辑器打开如图下,(如果你打开文件里面的标签没换行格式,那么你在myeclipse 新建一个jsp 文 ...
- vue重置data数据
可以通过this.$data获取当前状态下的data,通过this.$options.data()获取该组件初始状态下的data. 然后只要使用Object.assign(this.$data, th ...
- Ubuntu 解决TXT文本乱码问题
只要依次在终端输入这两行指令即可: gsettings set org.gnome.gedit.preferences.encodings auto-detected "['GB18030' ...
- 131、Java面向对象之static关键字三(使用static定义方法)
01.代码如下: package TIANPAN; class Book { // 描述的是同一个出版社的信息 private String title; private double price; ...
- 118、Java中String类之取字符串长度
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...
- 三 基于Java动态数组手写队列
手写队列: package dataStucture2.stackandqueue; import com.lt.datastructure.MaxHeap.Queue; import dataStu ...
- 【剑指Offer面试编程题】题目1372:最大子向量和--九度OJ
题目描述: HZ偶尔会拿些专业问题来忽悠那些非计算机专业的同学.今天JOBDU测试组开完会后,他又发话了:在古老的一维模式识别中,常常需要计算连续子向量的最大和,当向量全为正数的时候,问题很好解决.但 ...
- Python学习第三课——运算符
# 运算符 + - * / **(幂) %(取余) //(取整) num=9%2 print("余数为"+(str)(num)) #运算结果为 1 num1=9//2 print( ...
- 树莓派frp添加为服务管理
1.下载frp https://github.com/fatedier/frp/releases 我是1代的B+,下载arm版的,新的可以用arm64的 frp_0.29.0_linux_arm.ta ...
- Linux centosVMware su命令、sudo命令、限制root远程登录
一.su命令 Linux系统中有些事情只有root用户才能做,普通用户不能做,这时候就需要临时切换到root身份了. [root@davery ~]# whoamiroot [root@davery ...