HDU-1005 Number Sequence
This problem seems like a very huge problem, however, the answers have some certain regular pattern.
This problem seems like a very huge problem, however, the answers have some certain regular pattern.
The following analysis is from boss Tan when he taught me how to solve this problem. After passing the problem, I sum up his ideas and turned it into words.
Just loop and calculate violently.
This is just stimulation. At first I think the answer was m + m / k . However, I didn't think of that there may be given more than k days more.
Note that the answer can be very huge, so you need to use long long.
C++ has a set of very handy function for set. Here we just use UNION
This is a loop problem, you need to loop x from 1 to MAX to find if there is an x that fits it.
First sort all the original numbers. And then, add the first m biggest numbers one by one, we get biggest sums of first m * m numbers.
This problem is to judge whether the two numbers are relatively prime.
Just sort all the numbers, since the input numbers are odds, so the middle number is n / 2 + 1