zoukankan      html  css  js  c++  java
  • D.Little Sub and Balloons

    Description

    Little Sub is an ICPC participant.
    Every time when Little Sub solves a new problem, a balloon will be given to him. Different problems have distinct colors.
    However, volunteers may give multiple balloons of the same kind to participants when they solve the problem.
    Little Sub forgets how many problems he has solved in the last competition, but he still remember all balloons he received. Please help him calculate the number of passed problems.

    Input

    The first line contains one positive integer n(1 ≤ n ≤ 100), indicating the number of balloons. The following line contains n integers, indicating all the balloons. To simplify the problem, we mark
    different colors as different ids.
    All given integers will not exceed 2^31 − 1.

    Output

    Print one integer on the single line, indicating the answer.

    Author
    CHEN, Jingbang

    题义:统计一共出现了多少个不一样的数.
    数据范围小的话可以用桶排序.
    也可以直接用 STL容器的 set,输出size即可.
    #include <iostream>
    #include <set>
    #include <cstdio>
    typedef long long ll;
    using namespace std;
    set<ll> s;
    int main()
    {
        int n;
        ll tmp;
        scanf("%d",&n);
        for(int i=1;i<=n;i++) scanf("%I64d",&tmp),s.insert(tmp);
        cout<<s.size()<<endl;
        //cout << "Hello world!" << endl;
        return 0;
    }
    
  • 相关阅读:
    Codeforces Round #419 (Div. 2)
    论蒟蒻的自我修养
    12 day 1
    Balanced Teams (USACO Jan Bronze 2014)
    一个奇怪的绘图程序
    BZOJ 1002 [ FJOI 2007 ]
    BZOJ 3540 realtime-update 解题
    准备做的题目
    代码风格与树形DP
    CH round #55 Streaming #6
  • 原文地址:https://www.cnblogs.com/-yjun/p/10549907.html
Copyright © 2011-2022 走看看