CHEFHACK - WA

chefhack
wa

#1

I’m getting WA can anyone tell me what I’m doing wrong or the test case which fails in this.
http://www.codechef.com/viewsolution/1742653


#2

Try this test:

4
0 4 2 12
2 1 9 24
0 1 9 12
2 8 2 18

The answer is 2.
While your answer is 12.

UPD.
The answer is 12.
While your answer is 2.


#3

@cyberghost23 : In your submission , you are using Arrays.binarySearch() . However the length of the array of primes “p” is not exactly the number of primes till the range you have found them . You should store the number of primes which are valid entries in array of primes “p” . And then you should use the method Arrays.binarySearch(int [] array , int fromIndex , int endIndex , int value ) . Pass fromIndex = 0 and endIndex = number of valid prime entries in the array . If you do binary search on the whole array , there are some junk entries in the end of array , which make the results undefined as the array now may not be sorted due to junk entries and binary search will not be able to function properly .