当前位置: 首页 > news >正文

[PAT] 1041 Be Unique (20 分)Java

Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,104​​]. The first one who bets on a unique number wins. For example, if there are 7 people betting on { 5 31 5 88 67 88 17 }, then the second one who bets on 31 wins.

Input Specification:

Each input file contains one test case. Each case contains a line which begins with a positive integer N (105​​) and then followed by N bets. The numbers are separated by a space.

Output Specification:

For each test case, print the winning number in a line. If there is no winner, print None instead.

Sample Input 1:

7 5 31 5 88 67 88 17

Sample Output 1:

31

Sample Input 2:

5 888 666 666 888 888

Sample Output 2:

None

 1 package pattest;
 2 
 3 import java.io.BufferedReader;
 4 import java.io.IOException;
 5 import java.io.InputStreamReader;
 6 import java.util.ArrayList;
 7 import java.util.List;
 8 
 9 /**
10  * @Auther: Xingzheng Wang
11  * @Date: 2019/2/22 13:51
12  * @Description: pattest
13  * @Version: 1.0
14  */
15 public class PAT1041 {
16     public static void main(String[] args) throws IOException {
17         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
18         String[] sp = reader.readLine().split(" ");
19 
20         List<String> list1 = new ArrayList<>();
21         List<String> list2 = new ArrayList<>();
22         for (int i = 1; i < sp.length; i++) {
23             if (list1.contains(sp[i])){
24                 list2.add(sp[i]);
25             }else{
26                 list1.add(sp[i]);
27             }
28         }
29         list1.removeAll(list2);
30         if (list1.size() > 0){
31             System.out.print(list1.get(0));
32         }else{
33             System.out.print("None");
34         }
35     }
36 }

 

转载于:https://www.cnblogs.com/PureJava/p/10498067.html

相关文章:

  • 「CF1025D Recovering BST」
  • Python 装饰器
  • 研发管理工具Leangoo泳道实现Scrum任务看板
  • Codeforces Round 545 (Div. 2)
  • JQuery EasyUI 初始
  • 特殊字符
  • Ionic3关闭弹出页面,跳转到列表后刷新父页面
  • 【计算几何】二维凸包——Graham's Scan法
  • ArrayList中的一些小细节@JDK8
  • MySQL 连接 通过实例总结详解 笛卡尔积,自然连接,内连接,外连接
  • 前端的第一步
  • P3375 【模板】KMP字符串匹配
  • C++11并发——多线程std::thread (一)
  • unity下贴图混合(Texture Blending)
  • elasticsearch中ik词库配置远程热加载
  • 【Leetcode】101. 对称二叉树
  • 30天自制操作系统-2
  • CSS实用技巧
  • GitUp, 你不可错过的秀外慧中的git工具
  • HomeBrew常规使用教程
  • js
  • Next.js之基础概念(二)
  • nginx 配置多 域名 + 多 https
  • orm2 中文文档 3.1 模型属性
  • React的组件模式
  • TiDB 源码阅读系列文章(十)Chunk 和执行框架简介
  • 第十八天-企业应用架构模式-基本模式
  • 后端_MYSQL
  • 基于webpack 的 vue 多页架构
  • 快速构建spring-cloud+sleuth+rabbit+ zipkin+es+kibana+grafana日志跟踪平台
  • 力扣(LeetCode)56
  • 聊聊spring cloud的LoadBalancerAutoConfiguration
  • 前端js -- this指向总结。
  • 适配iPhoneX、iPhoneXs、iPhoneXs Max、iPhoneXr 屏幕尺寸及安全区域
  • 原创:新手布局福音!微信小程序使用flex的一些基础样式属性(一)
  • 格斗健身潮牌24KiCK获近千万Pre-A轮融资,用户留存高达9个月 ...
  • 机器人开始自主学习,是人类福祉,还是定时炸弹? ...
  • ​ 全球云科技基础设施:亚马逊云科技的海外服务器网络如何演进
  • #FPGA(基础知识)
  • (+4)2.2UML建模图
  • (9)STL算法之逆转旋转
  • (C#)Windows Shell 外壳编程系列4 - 上下文菜单(iContextMenu)(二)嵌入菜单和执行命令...
  • (LNMP) How To Install Linux, nginx, MySQL, PHP
  • (Python) SOAP Web Service (HTTP POST)
  • (笔试题)分解质因式
  • (附源码)ssm高校升本考试管理系统 毕业设计 201631
  • (附源码)计算机毕业设计ssm基于Internet快递柜管理系统
  • (淘宝无限适配)手机端rem布局详解(转载非原创)
  • (一)80c52学习之旅-起始篇
  • (转)四层和七层负载均衡的区别
  • (转载)Linux 多线程条件变量同步
  • .helper勒索病毒的最新威胁:如何恢复您的数据?
  • .NET 4.0中使用内存映射文件实现进程通讯
  • .Net 代码性能 - (1)
  • .net反编译工具