[Programming Questions] Be Unique (Gambler betting problem)

Source: Internet
Author: User

Being unique is, important to people on Mars, even their lottery is designed in a unique. 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 is 7 people betting on 5 to 5, then the second one who bets on wins.

Input Description:
Each input file contains the one test case. Each case contains a line which begins with a positive an integer n (<=105) and then followed by N bets. The numbers is separated by a space.

Output Description:
For each test case, print the winning number in a line. If There is no winner, print "None" instead.

Input Example:
7 5 31 5 88 67 88 17

Output Example:
31

#include <iostream>using namespace STD;intMain () {intNCin>> N;intar[10001] = {0};intbr[100001] = {1}; for(inti =1; i < N; i++) {Cin>> Br[i];    Ar[br[i]] + +; } for(inti =1; i < N; i++) {if(Ar[br[i]] = =1)        {cout<< Br[i] << Endl;return 0; }    }cout<<"None"<< Endl;return 0;}

[Programming Questions] Be Unique (Gambler betting problem)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.