Solution 1 (Easy to Understand)
Let's try out for small values of n to get a feel for the problem. When n=1,Sn is obviously 1. The problem states that for n=2,Sn is 4. Let's try it out for n=3.
Let's perform casework on the number of elements in A,B.
Case 1:∣A∣=∣B∣=1
In this case, the only possible equivalencies will be if they are the exact same element, which happens 3 times.
Case 2:∣A∣=∣B∣=2
In this case, if they share both elements, which happens 3 times, we will get 2 for each time, and if they share only one element, which also happens 6 times, we will get 1 for each time, for a total of 12 for this case.
Case 3:∣A∣=∣B∣=3
In this case, the only possible scenario is that they both are the set {1,2,3}, and we have 3 for this case.
In total, S3=18.
Now notice, the number of intersections by each element 1…3, or in general, 1…n is equal for each element because of symmetry - each element when n=3 adds 6 to the answer. Notice that 6=(24) - let's prove that Sn=n⋅(n−12n−2) (note that you can assume this and answer the problem if you're running short on time in the real test).
Let's analyze the element k - to find a general solution, we must count the number of these subsets that k appears in. For k to be in both A and B, we need both sets to contain k and another subset of 1 through n not including k. (A={k}∪A′∣A′⊂{1,2,…,n}∧A′⊂{k} and B={k}∪B′∣B′⊂{1,2,…,n}∧B′⊂{k})
For any 0≤l≤n−1 that is the size of both A′ and B′, the number of ways to choose the subsets A′ and B′ is (ln−1) for both subsets, so the total number of ways to choose the subsets are (ln−1)2. Now we sum this over all possible l's to find the total number of ways to form sets A and B that contain k. This is equal to ∑l=0n−1(ln−1)2. This is a simplification of Vandermonde's identity, which states that ∑k=0r(km)⋅(r−kn)=(rm+n). Here, m, n and r are all n−1, so this sum is equal to (n−12n−2). Finally, since we are iterating over all k's for n values of k, we have Sn=n⋅(n−12n−2), proving our claim.
We now plug in Sn to the expression we want to find. This turns out to be 2021⋅(20204040)2022⋅(20214042). Expanding produces 2021⋅4040!⋅2021!⋅2021!2022⋅4042!⋅2020!⋅2020!.
After cancellation, we have
2021⋅2021⋅20212022⋅4042⋅4041⟹2021⋅20214044⋅4041
4044 and 4041 don't have any common factors with 2021, so we're done with the simplification. We want to find 4044⋅4041+20212(mod1000)≡44⋅41+212(mod1000)≡1804+441(mod1000)≡2245(mod1000)≡245
~KingRavi ~Edited by MY-2
Solution 2 (Linearity of Expectation)
We take cases based on the number of values in each of the subsets in the pair. Suppose we have k elements in each of the subsets in a pair (for a total of n elements in the set). The expected number of elements in any random pair will be n⋅nk⋅nk by linearity of expectation because for each of the n elements, there is a nk probability that the element will be chosen. To find the sum over all such values, we multiply this quantity by (kn)2. Summing, we get
k=1∑nnk2(kn)2
Notice that we can rewrite this as
k=1∑nn1((k)!(n−k)!k⋅n!)2=k=1∑nn1n2((k−1)!(n−k)!(n−1)!)2=nk=1∑n(k−1n−1)2=nk=1∑n(k−1n−1)(n−kn−1)
We can simplify this using Vandermonde's identity to get n(n−12n−2). Evaluating this for 2022 and 2021 gives
2021(20204040)2022(20214042)=202132022⋅4042⋅4041=202122022⋅2⋅4041
Evaluating the numerators and denominators mod 1000 gives 804+441=1245
- pi_is_3.14
Solution 3 (Rigorous)
For each element i, denote xi=(xi,A,xi,B)∈{0,1}2, where xi,A=I{i∈A} (resp. xi,B=I{i∈B}).
Denote Ω={(x1,⋯,xn):∑i=1nxi,A=∑i=1nxi,B}.
Denote Ω−j={(x1,⋯,xj−1,xj+1,⋯,xn):∑i=jxi,A=∑i=jxi,B}.
Hence,
Sn=(x1,⋯,xn)∈Ω∑i=1∑nI{xi,A=xi,B=1}=i=1∑n(x1,⋯,xn)∈Ω∑I{xi,A=xi,B=1}=i=1∑n(x1,⋯,xi−1,xi+1,⋯,xn)∈Ω−i∑1=i=1∑nj=0∑n−1((jn−1))2=nj=0∑n−1((jn−1))2=nj=0∑n−1(jn−1)(n−1−jn−1)=n(n−12n−2).
Therefore,
S2021S2022=2021(20204040)2022(20214042)=202124044⋅4041.
This is in the lowest term. Therefore, modulo 1000,
p+q≡4044⋅4041+20212≡44⋅41+212≡(245) .
~Steven Chen (www.professorchenedu.com)
Solution 4
Let's ask what the contribution of an element k∈{1,2,⋯,n} is to the sum Sn=∑∣A∩B∣.
The answer is given by the number of (A,B) such that ∣A∣=∣B∣ and k∈A∩B, which is given by (n−12n−2) by the following construction: Write down 1 to n except k in a row. Do the same in a second row. Then choose n−1 numbers out of these 2n−2 numbers. k and the numbers chosen in the first row make up A. k and the numbers not chosen in the second row make up B. This is a one-to-one correspondence between (A,B) and the ways to choose n−1 numbers from 2n−2 numbers.
The contribution from all elements is therefore
Sn=n(n−12n−2).
For the rest please see Solution 1 or 2.
~qyang
NOTE: you may have a concern, "what if we chose the same element twice in a set?" Let us look at an example. Suppose we are partioning S4, k=4, and we list out the rows top: 1,2,3 bottom: 1,2,3 If we chose 1 (top) 2 (top) and 1 (bottom), then we can distribute these numbers by sending the numbers in the top row that were chosen to set A, which would be 1,2,4, and set B would be the numbers not chosen in the bottom row, which would be 2,3,4. To prove this rigourously, let x be the number of elements in the top row chosen and y be the number of elements chosen in the bottom row. Since we choose n−1 objects, x+y=n−1. So the amount of elements in A would be 1+x, and the amount of elements in B would be 1+(n−1−y)=1+n−1−(n−1−x)=x+1.
~eqb5000
Solution 5 (No strange notation, proof of all combo lemmas provided)
Assume the subset A of {1,2,3,…,n} has k elements, where k is some integer from 0 to n, inclusive. Then, there are (kn) ways to choose A. Now, we find the amount of ways to choose B, given A. Assume that A and B have a elements in common, where 0≤a≤k. Then, a of the elements in B are also in A, so we can pick (ak) elements here, and the remaining k−a elements in B are not in A, so we can pick (k−an−k) elements here. Therefore, there are (ak)(k−an−k) ways to select B if A and B have a elements in common.
However, if A and B have a elements in common, the ordered pair (A,B) will contribute a to the total sum. Thus, we multiply by a. Since the amount of ways to choose B ranges over all 0≤a≤k, we seek the sum;
(kn)∑a=0ka(ak)(k−an−k).
The (kn) on the outside of the sum represents the amount of ways to choose A. Now, we simplify the a(ak) term a little bit
Note that a(ak)=a⋅a!(k−a)!k!=(a−1)!(k−a)!k!=k⋅(a−1)!(k−a)!(k−1)!=k(a−1k−1)
The reason we did this is because we want the a in the combination expression, and not as a scale factor. Then, the sum simplifies to
(kn)∑a=0kk(a−1k−1)(k−an−k). We can take k out of the sum (it's a constant in the sum), and the sum turns into
k(kn)∑a=0k(a−1k−1)(k−an−k).
Now, we use a combinatorial identity called Vandermode's Identity (This identity is well known, if you don't know it, learn it; it's useful for these types of problems). Consider x+y people. We wish to form a committee with r people. We can do this in (rx+y) ways. However, we can choose k people from the group of x people and r−k people from the other y people, for all 0≤k≤r.
This is done in ∑k=0r(kx)(r−ky) ways, but this is also equal to (rx+y).
In our desired sum, we have x=k−1, y=n−k, and r=(a−1)+(k−a)=k−1. Thus, the summation part is equal to (k−1n−1), and the total product is k(kn)(k−1n−1).
Now, we want to sum this over all possible k, for 0≤k≤n.
This is ∑k=0nk(kn)(k−1n−1). We can do something with the k(kn) term that was similar to something we did last time to obtain that this is also equal to n(k−1n−1).
Then, the sum simplifies to n∑k=0n(k−1n−1)(k−1n−1)=n∑k=0n(k−1n−1)2.
We can use Vandermode's again, with x=y=n−1 and r=(k−1)+(k−1)=2k−2. Then, the sum is equal to n(n−12n−2).
Now, the problem seeks S2021S2022. This is equal to 2021(20204040)2022(20214042)=2020!⋅2020!2021⋅4040!2021!⋅2021!2022⋅4042!=2021⋅4040!⋅2021!⋅2021!2022⋅4042!⋅2020!⋅2020!=2021⋅2021⋅20212022⋅4042⋅4041=2021⋅20212022⋅2⋅4041.
We seek 2022⋅2⋅4041+2021⋅2021(mod1000). This is equivalent to 22⋅82+21⋅21≡804+441≡245(mod1000), and we are done.
Video Solution
https://youtu.be/cXJmHV5BnfY ~MathProblemSolvingSkills.com
https://youtu.be/wTYXkE32v9o ~AMC & AIME Training