#AJ1801. Digit Reassembly(初级)

Digit Reassembly(初级)

Description

Given a number less than 105010^{50}, answer various questions about the number based on the line of input:

  1. For Input Line #1: How many digits are in the number?
  2. For Input Line #2: What is the sum of all of the digits in the number?
  3. For Input Line #3: What is the sum of the digits at the odd locations? (The leftmost digit is Location #1).
  4. For Input Line #4: How many times does the digit 4 appear?
  5. For Input Line #5: What is the middle digit? If the length of the number, NN, is even, find the N/2N/2 number (again, the leftmost digit is the 1st1^{st} one).

Input Format

There will be 5 lines of input. Each will contain a positive integer less than 105010^{50}.

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". 9+8+7+6+5+4=399+8+7+6+5+4 = 39. 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 = 4+6+6=164+6+6=16. 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 N=6N=6. Since NN is even, we look for the N/2=3rdN/2 = 3^{rd} digit. The 3rd digit is 3.

1325678945
987654
456160
143295823976154
123456
10
39
16
2
3