#194. 数组最大特殊分数求和
数组最大特殊分数求和
Sum of Largest Special Scores
Background
Congcong is currently exploring special numbers within arrays. He is interested in efficiently finding specific values in an array.
Problem Description
Given two arrays, and , of non-negative integer scores. A "special" score is one which is a multiple of , such as or . Return the sum of the largest special score in and the largest special score in . To practice decomposition, write a separate helper method which finds the largest special score in an array. Write your helper method after your scoresSpecial() method.
Input Format
Input is given from standard input in the following format.
Two arrays, and . Each array's elements are space-separated and enclosed in square brackets
[], with the two arrays also separated by a space.
Output Format
Output to standard output in the following format.
An integer, representing the sum of the largest special scores from both arrays.
Sample
[12 10 4] [2 20 30]
40
[20 10 4] [2 20 10]
40
[12 11 4] [2 20 31]
20
Sample Explanation
Sample 1: The largest special score in array is . The largest special score in array is . Their sum is .
Sample 2: The largest special score in array is . The largest special score in array is . Their sum is .
Sample 3: Array has no special scores, so the largest special score is . The largest special score in array is . Their sum is .
Constraints
Time limit: second, Memory limit: KiB for each test case.