Number of functions , that assign 1 to exactly one of the positive integers less than or equal to 98, is equal to ______.
Solution
Core idea. Inputs not mentioned in a condition are free, and each doubles the count for a two-valued function.
Concept refresher. If one choice can be made in ways and an independent second choice in ways, both can be made together in
ways.
Picture the situation. The inputs 1 to 98 are restricted: exactly one of them is assigned the value 1 and the other 97 the value 0. The inputs 99 and 100 are not mentioned, so each may be assigned 0 or 1 freely.
Approach. Count the choices for the restricted inputs and for the free inputs, and multiply.
Step 1: The restricted inputs
The input among 1 to 98 that receives the value 1 can be chosen in 98 ways, and the rest of them receive 0.
Step 2: The free inputs
Each of 99 and 100 has 2 possible values, which is ways. So the number of functions is .
Answer. 392
Sanity check. Without the last two inputs the count would be 98, and each free input doubles it: .
Common wrong answers
- 98: Forcing 99 and 100 to map to 0 as well gives 98.
- 100: Letting exactly one of all the 100 inputs receive the value 1 gives 100, which ignores that 99 and 100 are free.
Key takeaway
The trap. A condition on some of the inputs says nothing about the others.
How toppers think. They split the domain into the restricted part and the free part before counting.
Remember.