Simulare🎅🏼🎄 | SubsetCheating

This was the problem page during the contest. Access the current page here.
Time limit: 0.08s Memory limit: 64MB Input: subset.in Output: subset.out

Task

Little Square and Little Triangle took a math test. Little Triangle didn’t study for the test, but, fortunately for him, Little Square, his best friend, succeeded in studying for the exam, so Little Triangle was able to copy parts of Little Square’s solutions on the test.

We know that the test had NN problems in total and that at each one of them Little Triangle’s score is not more than Little Square’s score. All scores are nonegative integers. We don’t know the exact score of any of them at any problem, but we know that in total Little Square has AA points while Little Triangle has BB points total.

Knowing NN (the number of problems that made up the math test), AA (the sum of the scores that Little Square got on the problems) and BB (Little Triangle’s sum of scores), we want to compute the number of ways in which the two of them could have been scored on the test, modulo 109+710^9 + 7.

Input data

The sole line of the input file subset.in will contain tree nonnegative integers NN, AA and B, separated by a single space, with the same meaning as explained above.

Output data

The output file subset.out will contain only one integer, representing the number of ways in which Little Square and Little Triangle could have been scored on the test, modulo 109+710^9 + 7.

Constraints

  • 1N1061 \leq N \leq 10^6
  • 0A,B1060 \leq A, B \leq 10^6
  • 22 ways of scoring are considered distinct (different) if Little Square or Little Triangle have a different number of points on at least one of the NN problems.
# Points Constraints
1 5 N2,0A,B103N \leq 2, 0 \leq A, B \leq 10^3
2 7 N2,0A,B106N \leq 2, 0 \leq A, B \leq 10^6
3 13 1N5,0A,B51 \leq N \leq 5, 0 \leq A, B \leq 5
4 15 1N106,B=0,0A1061 \leq N \leq 10^6, B = 0, 0 \leq A \leq 10^6
5 30 1N50,0A,B501 \leq N \leq 50, 0 \leq A, B \leq 50
6 30 No additional constraints.

Example 1

subset.in

2 3 2

subset.out

6

Explanation

In the first example, we have N=2N = 2 problems on the math test. Little Square has A=3A = 3 points in total, while Little Triangle has B=2B = 2 points in total. From now on let P1P1 be the first problem, and P2P2 the second problem.

There are 66 distinct ways in which Little Square and Little Triangle could have scored on the test:

  • Little Square: 00 points - P1P1, 33 points - P2P2; Little Triangle: 00 points - P1P1, 22 points - P2P2
  • Little Square: 11 points - P1P1, 22 points - P2P2; Little Triangle: 00 points - P1P1, 22 points - P2P2
  • Little Square: 11 points - P1P1, 22 points - P2P2; Little Triangle: 11 points - P1P1, 11 points - P2P2
  • Little Square: 22 points - P1P1, 11 points - P2P2; Little Triangle: 22 points - P1P1, 00 points - P2P2
  • Little Square: 22 points - P1P1, 11 points - P2P2; Little Triangle: 11 points - P1P1, 11 points - P2P2
  • Little Square: 33 points - P1P1, 00 points - P2P2; Little Triangle: 22 points - P1P1, 00 points - P2P2

Example 2

subset.in

2 4 6

subset.out

0

Example 3

subset.in

36 43 27

subset.out

207434534

Example 4

subset.in

100001 999999 888888

subset.out

991579070

Log in or sign up to be able to send submissions!