#71. 跳过13及其后数字求和

    ID: 71 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-2gesp1循环结构条件结构

跳过13及其后数字求和

Sum with Unlucky 13

Background

Congcong is playing a number game. He needs to calculate the sum of a series of numbers, but some numbers are considered unlucky and require special handling.

Problem Description

Return the sum of the numbers in the array, returning 00 for an empty array.

Except the number 1313 is very unlucky, so it does not count and numbers that come immediately after a 1313 also do not count.

Input Format

Input is given from Standard Input in the following format.

A single line containing multiple integers, representing the elements of the array.

Output Format

Output is to be printed to Standard Output in the following format.

A single integer, representing the calculated sum.

Sample

1 2 2 1
6
1 1
2
1 2 2 1 13
6

Sample Explanation

For the sample input 1 2 2 1 13: The numbers in the array are 1,2,2,1,131, 2, 2, 1, 13. 11 is counted. Current sum: 11. 22 is counted. Current sum: 1+2=31+2=3. 22 is counted. Current sum: 3+2=53+2=5. 11 is counted. Current sum: 5+1=65+1=6. 1313 is unlucky and not counted. The final sum is 66.

Constraints

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