参考一个博客的输入挂,先挂在此处,以备以后使用。

import java.io.*;
import java.util.*;
import java.math.*; public class Main
{ public static void main(String[] args)
{
InputReader in = new InputReader();
PrintWriter out = new PrintWriter(System.out); out.close();
}
}
class InputReader
{
BufferedReader buf;
StringTokenizer tok;
InputReader()
{
buf = new BufferedReader(new InputStreamReader(System.in));
}
boolean hasNext()
{
while(tok == null || !tok.hasMoreElements())
{
try
{
tok = new StringTokenizer(buf.readLine());
}
catch(Exception e)
{
return false;
}
}
return true;
}
String next()
{
if(hasNext()) return tok.nextToken();
return null;
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
BigInteger nextBigInteger()
{
return new BigInteger(next());
}
BigDecimal nextBigDecimal()
{
return new BigDecimal(next());
}
}

正确代码:

import java.io.*;
import java.util.*;
import java.math.*;
public class Main{
public static void main(String[] args) {
InputReader in = new InputReader();
PrintWriter out = new PrintWriter(System.out);
final int maxn = 100000+10;
int[] vis = new int[maxn];
int n = in.nextInt(), num, flag = 0;
for(int i = 0; i < n; i++) {
num = in.nextInt();
if(vis[num] == 1)
flag = 1;
vis[num] = 1;
}
if(flag == 0)
out.println("NO");
else
out.println("YES");
out.close();
}
} class InputReader{
BufferedReader buf;
StringTokenizer tok;
InputReader(){
buf = new BufferedReader(new InputStreamReader(System.in));
}
boolean hasNext() {
while(tok == null || !tok.hasMoreElements()) {
try {
tok = new StringTokenizer(buf.readLine());
}
catch(Exception e) {
return false;
}
}
return true;
}
String next() {
if(hasNext()) {
return tok.nextToken();
}
return null;
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
BigInteger nextBigInteger() {
return new BigInteger(next());
}
BigDecimal nextBigDecimal() {
return new BigDecimal(next());
}
}

【7-9 有重复的数据I (20 分)】【此题卡输入,需要自己写个输入挂】的更多相关文章

  1. 1073 Scientific Notation (20 分)

    1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very la ...

  2. 7-16 一元多项式求导(20 分)(有关while(scanf("%d",&n)!=EOF))

    7-16 一元多项式求导(20 分) 设计函数求一元多项式的导数. 输入格式: 以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过1000的整数).数字间以空格分隔. 输出格式: 以与输入相同 ...

  3. mongodb去除重复的数据(二)

    前天因为工作需要,开始着手对数据库中两千多万的数据中其中一个字段重复的数据进行去重. 原本使用一些测试的数据测试后,前天写的那个方法是可行的,但是当面对这个两千万的真实数据时,我却发现这方法有些不顶用 ...

  4. c# 如何中List<object>中去掉object对象中的重复列数据?

    //去掉重复 var title = modelList.GroupBy(m => m.Title.ToLower().Trim()).Select(m => new { ID = m.F ...

  5. SQl server 关于重复插入数据的测试

    最近发布的脚本,有那种防止重复插入数据(包括存在时更新,不存在是插入的处理,判断的方向可能与下面的示例相反) 使用类似下面的 SQL declare @id int, @value int if no ...

  6. 使用aggregate在MongoDB中查找重复的数据记录

    我们知道,MongoDB属于文档型数据库,其存储的文档类型都是JSON对象.正是由于这一特性,我们在Node.js中会经常使用MongoDB进行数据的存取.但由于Node.js是异步执行的,这就导致我 ...

  7. C#中去掉表中重复的数据

    /// <summary> /// 去掉表中重复的数据  int /// </summary> /// <param name="SourceTable&quo ...

  8. 如何去掉list里重复的数据

    去掉list重复的数据,目前总结的以下三种方法,分别是采用set集合来做.两层循环不用任何方法来做,以及一层循环采用contains()方法来做,如下: 1.采用set结合来做: package te ...

  9. Excel如何查找名字重复的数据

    来源于:http://jingyan.baidu.com/article/414eccf6091ff86b431f0aec.html Cokery今天在帮助同事整理数据的时候遇到了一个难题,就是在Ex ...

随机推荐

  1. salt远程实现go编译重启

    使用salt实现jenkins发版时,远程对go项目编译重启 1.go 版本1.12 使用go mod 2.设置go镜像 GOPROXY="https://goproxy.io" ...

  2. tcp端口扫描与syn扫描

    连接网络设备时,一般都会在网络设备端选取0-65535之间的一个端口进行连接,端口扫描是指:检查网络设备上0-65535号端口哪些端口是开启状态.如果黑客扫描到某网络设备的80端口是开启状态,那么很有 ...

  3. opencc介绍

    1.什么是opencc? Open Chinese Convert(OpenCC)是一个开源的中文简繁转换项目,致力于制作高质量的基于统计预料的简繁转换词库.还提供函数库(libopencc).命令行 ...

  4. RobotFrameWork中使用Chrome浏览器

    RF默认使用的是Firefox浏览器,如果要修改为其他浏览器要怎么做呢? 1.按F5搜索关键字[Open Browser],可以看到其帮助信息中说明了不同浏览器时browser参数的值 2.Pytho ...

  5. SQLite数据库简介和使用

    一.Sqlite简介: SQLite (http://www.sqlite.org/),是一款轻型的数据库,是遵守ACID的关联式数据库管理系统,它的设计目标是嵌入式的,而且目前已经在很多嵌入式产品中 ...

  6. C# int uint long ulong byte sbyte float double decimal 范围,及类型!

    static void Main(string[] args) { Console.WriteLine(" byte {0,7:g}{1,32:g}{2,32:g}",typeof ...

  7. PLC采集与控制,实现MES工序管理与品质管控,记录产品的加工数据,工厂生产装配流水线的一次成功应用

    1.通过程序与PLC的采集与控制,实现MES工序管理,品质管控,历史数据追溯的目的 2.大概的流程图 3.有三个地方相关联来实现以上功能,首先是MES的工序管理,设置指定的产品有那些工序,上位机程序扫 ...

  8. 收藏单词TOEFL备份托福英语

    TOEFL托福词汇串讲(文本) alchemy(chem-化学)n. 炼金术 chemistry 化学 alder 赤杨树 联想:older 老人坐在赤杨树下 sloth 树懒 algae n.海藻 ...

  9. 向Spring 容器中注入对象的几种方法

    1.使用@Bean 注解,用于注入第三方 jar 包到SpringIOC容器中. 2.使用 @Import({Order.class, Member.class, MyImportBeanDefini ...

  10. Visual Studio 2019 XAML Hot Reload功能介绍

    Visual Studio 2019提供了XAML Hot Reload功能,这个功能可以让WPF程序运行以后仍然可以修改XAML代码,并实时显示. XAML Hot Reload功能在Blend F ...