PATA1041 Be Unique

举报
陈沧夜 发表于 2022/04/29 22:43:28 2022/04/29
【摘要】 1041 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 c...

1041 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,10​4​​]. 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 (≤10​5​​) 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 <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main(void)
  5. {
  6. int a[100001] = {0};
  7. int b[100001] = {0};//用来区别该数字是否重复出现
  8. int n,flag=0;
  9. cin >> n;
  10. for (int i = 0; i < n; i++)
  11. {
  12. cin >> a[i];
  13. b[a[i]]++;
  14. }
  15. for (int i = 0; i < n; i++)
  16. {
  17. if (b[a[i]] == 1)
  18. {
  19. cout << a[i] << endl;
  20. return 0;
  21. }
  22. }
  23. if (flag == 0)
  24. cout << "None" << endl;
  25. return 0;
  26. }

 

文章来源: blog.csdn.net,作者:沧夜2021,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/CANGYE0504/article/details/88836334

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。