• pat1041. Be Unique (20)


    1041. Be Unique (20)

    时间限制
    100 ms
    内存限制
    65536 kB
    代码长度限制
    16000 B
    判题程序
    Standard
    作者
    CHEN, Yue

    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<algorithm>
     3 #include<iostream>
     4 #include<cstring>
     5 #include<queue>
     6 #include<vector>
     7 #include<cmath>
     8 #include<string>
     9 #include<map>
    10 #include<set>
    11 using namespace std;
    12 int num[10005];
    13 int main(){
    14     int n;
    15     scanf("%d",&n);
    16     memset(num,0,sizeof(num));
    17     vector<int> v;
    18     int i,in;
    19     for(i=0;i<n;i++){
    20         scanf("%d",&in);
    21         num[in]++;
    22         v.push_back(in);
    23     }
    24     for(i=0;i<v.size();i++){
    25         if(num[v[i]]==1){
    26             break;
    27         }
    28     }
    29     if(i==v.size()){
    30         printf("None
    ");
    31     }
    32     else{
    33         printf("%d
    ",v[i]);
    34     }
    35     return 0;
    36 }
  • 相关阅读:
    “百度杯”CTF比赛 九月场 code
    初识thinkphp(3)
    i春秋CTF web题(1)
    初识thinkphp(2)
    初识thinkphp(1)
    0MQ底层队列设计
    0MQ文档导读
    LF模式是个坑,ZeroIce中间件让你体会这个痛
    0xe7f001f0!?NDK调试过程,无故抛出SIGSEGV。
    KDevelop
  • 原文地址:https://www.cnblogs.com/Deribs4/p/4770307.html
Copyright © 2020-2023  润新知