hdu 1563

地址:http://acm.hdu.edu.cn/showproblem.php?pid=1563

题意:找n个数里只出现了1次的数。

mark:hash搞之。大于200的最小素数是211。

代码:

# include <stdio.h>
# include <string.h>


int dp[211][2] ;


void insert (int n)
{
int idx = n % 211 ;
while (dp[idx][0] != n && dp[idx][1] != 0)
idx++ ;
dp[idx][0] = n ;
dp[idx][1] ++ ;
}


int main ()
{
int i, n, num ;
while (~scanf ("%d", &n), n)
{
memset (dp, 0, sizeof(dp)) ;
for (i = 0 ; i < n ; i++)
{
scanf ("%d", &num) ;
insert(num) ;
}
for (i = 0 ; i <= 210 ; i++)
if (dp[i][1] == 1) printf ("%d\n", dp[i][0]) ;
}
return 0 ;
}



原文地址:https://www.cnblogs.com/lzsz1212/p/2316262.html