zoukankan      html  css  js  c++  java
  • 【7-9 有重复的数据I (20 分)】【此题卡输入,需要自己写个输入挂】

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

    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());
    	}
    }
    
    
  • 相关阅读:
    柯西恒等式 FPGA中信号的跨时钟域处理模板(二)
    OSPF
    Windows多网卡路由设置
    使用线程时需要注意的地方
    dicom 影像通信(scu、scp)的c-echo、c-store、c-find、c-move
    关于python3没有numpy和matplotlib库怎么办
    使用centos6.5时的几个小问题
    关于用Apache Beam跑WordCount
    MarkdownPad2的安装、破解和汉化
    安装Photoshop CS64
  • 原文地址:https://www.cnblogs.com/KeepZ/p/11604867.html
Copyright © 2011-2022 走看看