Posted on 2010-08-09 09:22
MiYu 阅读(344)
评论(0) 编辑 收藏 引用 所属分类:
ACM ( 水题 ) 、
ACM ( 杂题 )
MiYu原创, 转帖请注明 : 转载自 ______________白白の屋
题目地址:
http://acm.hdu.edu.cn/showproblem.php?pid=1235
很谁的题, 直接 hash 就可以了.
代码如下 :
#include <iostream>
#include <map>
using namespace std;
int main ()
{
int N;
while ( scanf ( "%d",&N ) , N )
{
map < int ,int > mp;
int num;
for ( int i = 0; i != N; ++ i )
{
scanf ( "%d",&num );
mp[num] ++;
}
scanf ( "%d",&num );
cout << mp[num] << endl;
}
//getchar();
return 0;
}
main (N,num)
{int scr[101],i;while(scanf("%d",&N),N){
memset ( scr , 0, sizeof ( scr ) );
for (i = 0; i != N; ++ i )
{scanf ( "%d",&num );scr[num] ++;}
scanf ("%d",&num);
printf ("%d\n",scr[num]);}
}