zoukankan      html  css  js  c++  java
  • A1041. Be Unique

    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 #include<cstdio>
     2 #include<iostream>
     3 using namespace std;
     4 int hashTB[10001] = {0,0}, record[100000];
     5 int main(){
     6     int N, find = -1;
     7     scanf("%d", &N);
     8     for(int i = 0; i < N; i++){
     9         scanf("%d", &record[i]);
    10         hashTB[record[i]]++;
    11     }
    12     for(int i = 0; i < N; i++){
    13         if(hashTB[record[i]] == 1){
    14             find = i;
    15             break;
    16         }
    17     }
    18     if(find == -1)
    19         printf("None");
    20     else printf("%d", record[find]);
    21     cin >> N;
    22     return 0;
    23 }
    View Code

    总结:

    1、本题题意:按照输入的顺序,找出第一个只出现一次的数字并输出。

  • 相关阅读:
    Git从入门到放弃
    Flex布局
    网络模型与TCP协议
    命令行技巧
    React环境搭建及部署
    Vue环境搭建及部署
    Python 集合set()
    Python-100天代码
    删除Windows启动管理器下的加载项
    windos7操作系统下easyBCD2.3安装Ubuntu18.04.1-desktop-amd64.iso双系统
  • 原文地址:https://www.cnblogs.com/zhuqiwei-blog/p/8495463.html
Copyright © 2011-2022 走看看