2013
12-12

# HDU 1563 Find your present!-动态规划-[解题报告] C++

In the new year party, everybody will get a "special present".Now it’s your turn to get your special present, a lot of presents now putting on the desk, and only one of them will be yours.Each present has a card number on it, and your present’s card number will be the one that different from all the others.For example, there are 5 present, and their card numbers are 1, 2, 3, 2, 1.so your present will be the one with the card number of 3, because 3 is the number that different from all the others.

The input file will consist of several cases.
Each case will be presented by an integer n (1<=n<=200, and n is odd) at first. Following that, n positive integers will be given in a line. These numbers indicate the card numbers of the presents.n = 0 ends the input.

For each case, output an integer in a line, which is the card number of your present.

5
1 1 3 2 2
3
1 2 1
0

3
2

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 ;
}

1. 题本身没错，但是HDOJ放题目的时候，前面有个题目解释了什么是XXX定律。
这里直接放了这个题目，肯定没几个人明白是干啥

2. Thanks for taking the time to examine this, I really feel strongly about it and love studying a lot more on this topic. If possible, as you acquire experience