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
Since the data is every small, you just need to loop and calculate until you find a answer that is bigger than the given number.
You can easily see that the law of ciphers is that each letter moves 21 bits backward. The 26 letters form a circle to support the law. However, in the ascii code, the letters are not a circle so you need to judge separately.
This is a sorting problem, you can either use quick sort or bubble sort or other sorts.