PAT Advanced 1041 Be Unique (20 分)

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]. 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 (≤) 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
#include <iostream>
using namespace std;
int main(){
    int T;
    cin>>T;
    int va[T],coun[10001];
    for(int i=0;i<T;i++){
        scanf("%d",&va[i]);
        coun[va[i]]++;
    }
    bool has=false;
    for(int i=0;i<T;i++){
        if(coun[va[i]]==1) {
            cout<<va[i];
            has=true;
            break;
        }
    }
    if(!has) cout<<"None";
    system("pause");
    return 0;
}

原文地址:https://www.cnblogs.com/littlepage/p/11355648.html

时间: 2024-10-08 08:00:43

PAT Advanced 1041 Be Unique (20 分)的相关文章

PAT 甲级 1041 Be Unique (20 分)(简单,一遍过)

1041 Be Unique (20 分) 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]. The first one who bets on a unique number wins. For example

PAT Advanced 1041 Be Unique (20) [Hash散列]

题目 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, 10^4]. The first one who bets on a unique number wins. For example, if there ar

【PAT甲级】1041 Be Unique (20 分)(多重集)

题意: 输入一个正整数N(<=1e5),接下来输入N个正整数.输出第一个独特的数(N个数中没有第二个和他相等的),如果没有这样的数就输出"None". 代码: #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;multiset<int>st;int a[100007];int main(){ ios::sync_with_stdio(false); cin.tie(

PAT Advanced 1132 Cut Integer (20分)

Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting to see that Z can be devided by the product of A

PAT Advanced 1152 Google Recruitment (20 分)

In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit prime found in consecutive digits of the natural co

PAT Advanced 1152 Google Recruitment (20分)

In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit prime found in consecutive digits of the natural co

PAT:1041. Be Unique (20) AC “段错误:可能是数组开的不够大”

#include<stdio.h> #include<string.h> int harsh[10066]; int arr[100066]; int main() { memset(harsh,0,sizeof(harsh)); memset(arr,0,sizeof(arr)); int n; scanf("%d",&n); for(int i=0 ; i<n ; ++i) { int tmp; scanf("%d",&am

PAT Advanced 1050 String Subtraction (20 分)

Given two strings S?1?? and S?2??, S=S?1??−S?2?? is defined to be the remaining string after taking all the characters in S?2?? from S?1??. Your task is simply to calculate S?1??−S?2?? for any given strings. However, it might not be that simple to do

PAT Advanced 1096 Consecutive Factors (20分)

Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the three consecutive numbers. Now given any positive N, you are supposed to find the maxim