Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int i = 0; i < a.length; ++i)
- {
- if(k%i == 0)
- if (binary_search(a , 0, a.length - 1, k/i))
- return true;
- }
- return false;
- bool binary_search(int[] a, int low, int high, int x)
- {
- if (high <= 1)
- return false;
- int mid = 1 + (high-1)/2;
- if(a[mid] == x)
- return true;
- if (a[mid] > x)
- return binary_search(a, 1, mid - 1, x);
- return binary_search(a, mid+1, high, x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement