GoodNumbers
TCO13 Semifinal 2 · 2013-02-19 · by snuke
Problem Statement
You are given
Constraints
- N will be between 1 and 1,000,000,000, inclusive.
- a will contain between 1 and 10 elements, inclusive.
- a and b will contain the same number of elements.
- Each element of a and b will be between 1 and N, inclusive.
{4}
{3}
20
Returns: 4
4, 8, 12, 16 and 20 are multiples of 4, but 12 is a multiple of 3. Thus 4, 8, 16 and 20 are good numbers.
{3,2}
{2,3}
9
Returns: 5
3 and 9 satisfy the condition for i=0. 2, 4 and 8 satisfy the condition for i=1. 2, 3, 4, 8 and 9 are good numbers.
{5,15,5,15}
{4,4,2,2}
50
Returns: 8
{1}
{1}
1000
Returns: 0
No number satisfies the condition.
{168120222,756,408,194,681,856,964,677,250,845}
{809,652,204,532,420,10,640688057,55,174076738,318}
1000000000
Returns: 16328141
Submissions are judged against all 88 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class GoodNumbers with a public method int count(vector<int> a, vector<int> b, int N) · 88 test cases · 2 s / 256 MB per case