#152. 青少年数字求和与函数应用

    ID: 152 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatLogic-2gesp4函数条件结构

青少年数字求和与函数应用

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, a,b,ca, b, c, return their sum. However, if any of the values is a "teen" -- in the range 13..1913..19 inclusive -- then that value counts as 00, except 1515 and 1616 do not count as teens. Write a separate helper function public int fixTeen(int n) that takes an integer value nn 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.

aa bb cc

Output Format

Output is printed to standard output in the following format.

sumsum

Sample

1 2 3
6
2 13 1
3
2 1 14
3

Sample Explanation

  • Sample 1: 1,2,31, 2, 3 are not in the 13..1913..19 range, so the sum is 1+2+3=61+2+3=6.
  • Sample 2: 1313 is a teen number, fixed to 00. So the sum is 2+0+1=32+0+1=3.
  • Sample 3: 1414 is a teen number, fixed to 00. So the sum is 2+1+0=32+1+0=3.

Constraints

Time limit 11 second, memory limit 10241024 KiB for each test case.