So i was trying to solve this problem.
You are given a multiset of N integers. Please find such a nonempty subset of it that the sum of the subset's elements is divisible by N. Otherwise, state that this subset doesn't exist.
What i did was simply generate the combinations and check if each of them was divisible by its cardinality. This solution turned out just fine.
After the competetion i found an elegant solution here.
It so turns out that i cannot generate a sequence of n numbers without having a consecutive subset which is not a multiple of n.
That is to say, whatever combination of numbers i try..there always exists a consecutive subset which is a multiple of 'No. of numbers'(n).
Can anyone explain this theoritically? Or is there any theorem that states this?
PS: I already tried Googling it...all in vain.
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i-1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
This is a classic application of Pigeonhole. Let the terms be a1, a2, …, an. Consider the n sums s1s2sn=a1,=a1+a2,…,=a1+a2+⋯+an. If any of these sums are divisible by n, then we are done.
Otherwise, each of these sums are congruent to one of 1, 2, …, n−1 modulo n. There are n sums and n−1 possible residues modulo n, so by Pigeonhole, two residues must be the same. In other words, there exist i and j, i<j, such that si≡sj(modn). Then sj−si=ai+1+ai+2+⋯+aj is divisible by n, as desired.
Furthermore, the example a1=a2=⋯=an−1=1 shows that you need at least n terms to guarantee that you can find a sum of consecutive terms that are divisible by n.
Log in to reply
Oh. I first though to apply Pigeonhole to a different part of the problem. @Sreejato Bhattacharya remember that Pigeonhole trick/thing you showed me? By the way I'm totally showing that to the class. :D
Log in to reply
Cool! :)
nice
Interesting problem. Possibly a Pigeonhole argument is needed?
not a question