1514_Fake Tickets
来源:互联网 发布:昆仑决 知乎 编辑:程序博客网 时间:2024/04/30 14:04
Your school organized a big party to celebrate your team brilliant win in the prestigious, worldfamous ICPC (International Collegiate Poetry Contest). Everyone in your school was invited for an evening which included cocktail, dinner and a session where your team work was read to the audience. The evening was a success - many 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 scanner 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 many tickets in the pack had 'clones', 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 should 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
*************************************************************************************************************************
#include<iostream>//印刷的正版票号从1到n,所以从1到n检测pack里面的号,有存在两个相同号码的,计数器+1
using namespace std;
#define max 20000
int main()
{
int n,m;
int pack[max];
int count;
int num;
while(cin>>n>>m&&n)
{
for(int i=0;i!=m;i++)
cin>>pack[i];
num=0;
for(int i=1;i<=n;i++)
{
count=0;//位置
for(int j=0;j!=m;j++)
{
if(i==pack[j])
++count;
if(count==2)
{
++num;
break;
}
}
}
cout<<num<<endl;
}
return 0;
}
- 1514_Fake Tickets
- zoj 1514 Fake Tickets
- ZOJ 1514 Fake Tickets
- zoj 1514 Fake Tickets
- 1514:Fake Tickets
- zoj 1514 Fake Tickets
- Tickets
- Tickets
- Tickets
- Tickets
- p2346_Lucky Tickets
- lucky tickets
- Buy Tickets
- HDU1260 Tickets
- poj2828Buy Tickets
- Buy Tickets
- poj2828Buy Tickets
- HDU1260 Tickets
- 处理oracle坏块
- 修改触摸屏校准程序文字
- redmine插件安装
- Ext.Net 1.x_Ext.Net.Grid拖动行排序,【最上】【最下】【上移】【下移】按钮排序
- (转)基础总结篇之七:ContentProvider之telephony读写短消息
- 1514_Fake Tickets
- 创新or改进不足?
- NHibernate与Hibernate
- Java 中的数据类型总结
- 多线程的创建例子
- 着陆页优化:少即是多
- 挂载U盘
- SQL Server 视图创建
- Android SDK 模拟器 快捷键 (模拟 旋转屏幕 轨迹球等)