Find The Units Digit
题目
Write every whole number from to as a 100-digit string, padding with leading zeros. For each string, multiply its nonzero digits together (the all-zero string counts as ). Add up all of these products. What is the last digit of the total?
For example, the ten 1-digit strings to give .
解析
先自己试一试,卡住了再打开提示。
提示 1
Ignoring a zero in a product is the same as multiplying by . Give each digit a weight: , and for .
提示 2
Each string's product is the product of its digits' weights. Can you write the sum over all strings as one product of 100 identical brackets?
查看解析
Method 1: one expansion
Step 1: Turn "ignore the zeros" into a weight. Multiplying by changes nothing, so ignoring a zero is the same as counting it as . Define
The product of the nonzero digits of a string is then . This also handles the all-zero string, whose product is .
Step 2: The whole sum is one expansion. Look at
Expanding it means picking one digit from each of the 100 brackets and multiplying their weights. Every 100-digit string gets picked exactly once, and its term is exactly its product of nonzero digits. So this expansion is the sum we want.
Step 3: Evaluate. Each bracket is , so
Method 2: build the strings one digit at a time
Let be the sum of the products over all -digit strings (leading zeros allowed, the all-zero string counting as ). We want .
Start: . The strings have products , so
From 1 digit to 2 digits, worked out. Every 2-digit string is a 1-digit string with one more digit stuck on the end. Group the strings by that last digit:
- Last digit : . The extra changes no product, so these give .
- Last digit (for example): . The extra multiplies every product by : . These give .
- Last digit , for each : the same argument gives .
Adding the ten groups:
The general step. Nothing above used the fact that the front part had just one digit. Adding a last digit to every -digit string gives
Unroll it.
Both methods give the same total: Method 1 multiplies all 100 factors of at once, Method 2 adds them one digit at a time.
Last digit
ends in , so every power of ends in :
Answer: .