ng.newbie
ng.newbie

Reputation: 3218

Example in TopCoder violates constraints

I am trying to understand the question DivFreed2 on TopCoder:

It specifically specifies that arrays

My problem is the third constraint with respect to the first example given:

2
2
Returns: 3
The three arrays Hero likes are {1,1}, {1,2}, and {2,2}.

Shouldn't the answer be 4 ? What happened to the array {2,1} ? There are 3 arrays that can be generated following the mentioned constraints, but thre is also a fourth array that can be generated which is {2,1}. No where in the question is it written that we can only have unique combinations of the numbers. Why aren't we including {2,1} in the list of arrays that can be valid ?

All the questions specify is the constraint of the arrangement of the numbers.

Am I missing something here ? Does an array of numbers mean the unique combination ?

Upvotes: 0

Views: 43

Answers (1)

Andrey Tyukin
Andrey Tyukin

Reputation: 44918

Well, 2 > 1, and 2 % 1 == 0, therefore

!(2 <= 1) && !(2 % 1 != 0)

therefore {2, 1} is not a solution.

Upvotes: 1

Related Questions