#152. 青少年数字求和与函数应用
青少年数字求和与函数应用
No Teen Sum
Background
Congcong is learning programming and encountered an interesting problem. He needs to calculate the sum of three integers, but with special rules for certain numbers.
Problem Description
Given three integer values, , return their sum. However, if any of the values is a "teen" -- in the range inclusive -- then that value counts as , except and do not count as teens.
Write a separate helper function public int fixTeen(int n) that takes an integer value and returns that value fixed for the teen rule. In this way, you avoid repeating the teen code three times (i.e., "decomposition"). Define the helper below and at the same indent level as the main sum logic.
Input Format
Input is given from standard input in the following format.
Output Format
Output is printed to standard output in the following format.
Sample
1 2 3
6
2 13 1
3
2 1 14
3
Sample Explanation
- Sample 1: are not in the range, so the sum is .
- Sample 2: is a teen number, fixed to . So the sum is .
- Sample 3: is a teen number, fixed to . So the sum is .
Constraints
Time limit second, memory limit KiB for each test case.