A. Olympiad
题目描述
The recent All-Berland Olympiad in Informatics featured n participants with each scoring a certain amount of points.
As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the following criteria:
At least one participant should get a diploma.
None of those with score equal to zero should get awarded.
When someone is awarded, all participants with score not less than his score should also be awarded.
Determine the number of ways to choose a subset of participants that will receive the diplomas.
输入
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of participants.
The next line contains a sequence of n integers a1, a2, …, an (0 ≤ ai ≤ 600) — participants’ scores.
It’s guaranteed that at least one participant has non-zero score.
输出
Print a single integer — the desired number of ways.
样例
inputCopy
4
1 3 3 2
output
3
inputCopy
3
1 1 1
output
1
inputCopy
4
42 0 0 42
output
1
题意
就是求不重复的数字除了0有几个
set搞一下
AC代码
#include <bits/stdc++.h>
using namespace std;
#define CLR(a,b) memset(a,(b),sizeof(a))
#define LL long long
const int MAXN = 1e3+10;
const double eps = 1e-15;
int main()
{
int n, x;
cin >> n ;
set<int> s;
for(int i = 0; i < n; i++)
cin >> x, s.insert(x);
int k = s.size();
// set<int>::iterator it;
// for(it = s.begin(); it != s.end(); it++) {
// if(*it)
// k++;
// }
if(*s.begin()==0) k -= 1;
cout << k << endl;
return 0;
}