#75. 检查数组中2的和是否为8

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

检查数组中2的和是否为8

Check if Sum of Twos is 8

Background

Congcong is playing a number game where he needs to check if certain arrays meet specific conditions.

Problem Description

Given an array of integers, return true if the sum of all occurrences of the number 22 in the array is exactly 88. Otherwise, return false.

Input Format

Input is given from standard input in the following format.

A single line containing multiple space-separated integers. These integers might be enclosed in square brackets [], but you should only process the numbers within.

Output Format

Output is printed to standard output in the following format.

Output true if the sum of all occurrences of the number 22 in the array is exactly 88; otherwise, output false.

Sample

[2 3 2 2 4 2]
true
[2 3 2 2 4 2 2]
false
[1 2 3 4]
false

Sample Explanation

Sample 1: The array [2 3 2 2 4 2] contains four 22s. Their sum is 2+2+2+2=82+2+2+2 = 8. Thus, true is output.

Sample 2: The array [2 3 2 2 4 2 2] contains five 22s. Their sum is 2+2+2+2+2=102+2+2+2+2 = 10. This is not equal to 88, so false is output.

Sample 3: The array [1 2 3 4] contains one 22. Its sum is 22. This is not equal to 88, so false is output.

Constraints

Time limit: 11 second per test case. Memory limit: 10241024 KiB per test case.