#AJ1801. Digit Reassembly(初级)
Digit Reassembly(初级)
Description
Given a number less than , answer various questions about the number based on the line of input:
- For Input Line #1: How many digits are in the number?
- For Input Line #2: What is the sum of all of the digits in the number?
- For Input Line #3: What is the sum of the digits at the odd locations? (The leftmost digit is Location #1).
- For Input Line #4: How many times does the digit 4 appear?
- For Input Line #5: What is the middle digit? If the length of the number, , is even, find the number (again, the leftmost digit is the one).
Input Format
There will be 5 lines of input. Each will contain a positive integer less than .
Output Format
For each line of input, print the answer to the corresponding question defined in the Description.
Explanation
Line 1: Input 1325678945. The question is "how many digits?". Counting the digits results in 10.
Line 2: Input 987654. The question is "sum of all digits". .
Line 3: Input 456160. The question is "sum of digits at odd locations". Locations 1, 3, and 5 correspond to digits 4, 6, and 6. Sum = .
Line 4: Input 143295823976154. The question is "count the digit 4". The digit 4 appears twice.
Line 5: Input 123456. The question is "middle digit". Length . Since is even, we look for the digit. The 3rd digit is 3.
1325678945
987654
456160
143295823976154
123456
10
39
16
2
3