Zoj problem set-1514 fake tickets

Source: Internet
Author: User

Time Limit: 2 seconds memory limit: 65536 KB

Your school organized a big party to celebrate your team brilliant win in the prestigious, worldfamicpc (International Collegiate poetry contest ). everyone in your school was invited for an evening which shortded cocktail, dinner and a session where your team work was read to the audience. the evening was a success-since more people than you expected showed interested in your poetry-although some critics of yours said it was food rather than words that attracted such an audience.
Whatever the reason, the next day you found out why the school hall had seemed so full: the school director confided he had discovered that several of the tickets used by the guests were fake. the real tickets were numbered sequentially from 1 to n (n <= 10000 ). the Director suspects some people had used the school program and printer from the computer room to produce copies of the real tickets. the Director gave you a pack with all tickets collected from the guests at the party's entrance, and asked you to determine how to handle tickets in the pack had 'clone', that is, another ticket with the same sequence number.

Input
The input contains data for several test cases. each test case has two lines. the first line contains two integers n and M which indicate respectively the number of original tickets and the number of persons attending the party (1 <=n <= 10000 and 1 <= m <= 20000 ). the second line of a test case contains M integers Ti representing the ticket numbers in the pack the Director gave you (1 <= Ti <= N ). the end of input is indicated by N = m = 0.

Output
For each test case your program shocould print one line, containing the number of tickets in the pack that had another ticket with the same sequence number.

Sample Input

5 5
3 3 1 2 4
6 10
6 1 3 6 6 4 2 3 1 2
0 0

Sample output

1
4

Source:South America 2002, practice

The question is how many tickets are copied, not the number of fake tickets!

#include<iostream>
#include<set>
using namespace std;
int main()
{
  int n,m;
  while(cin>>n>>m && (n || m))
  {
    int tickets;
    set<int> s,s0;
    while(m-- && cin>>tickets)
    {
      if(s.find(tickets) != s.end())
        s0.insert(tickets);
      else
        s.insert(tickets);
    }
    cout<<s0.size()<<endl;
  }
  return 0;
}

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.