Gautam and Subhash are the other. They is similar to the other in all respects except one. They has different ways of searching. When Gautam have to search for an item from a lot, he goes through all the items one by one and stops when he finds the ITE M. However Subhash have an entirely different and interesting of the searching. However the search works only for items which is sorted. He goes to the middle of the lot, if he finds the desired item, he stops, if no, he checks whether the middle item is SMA Ller or larger than the required item. If larger, he repeats the same process for the first half of the lot, otherwise second half. One day, the both of the contest in a and which they has to find a name out of a sorted dictionary. Whoever finds out the name first would win the contest. The audience is very eager to know who would win and hence they want you to predict.
Input:
The first line of input takes the number of test cases, T.
The next T lines take the total number of names N, followed by m. the position of the name to being searched, as well as the A Mount of time taken for each observation by Gautam G and Subhash S.
Output:
Print 1 in case Gautam would win, 2 in case Subhash would win, 0 in case of a draw in a separate line.
Constraints:
1<=t<=100
1<=n<=1000
1<=m<=n
1<=g<=100
1<=s<=100
Example:
Input:
310 8 10 2510 8 10 3010 8 10 12
Output:
222
Here is my Code implementation, C + +
#include <iostream>using namespacestd;intMain () {intN; CIN>>N; while(n--) { intNum,index,g,s,gtime,stime; CIN>>num; CIN>>index; CIN>>G; CIN>>s; intL=1, r=num,mid,sci=0; Gtime=index*G; while(l<=r) {Mid= (l+r) >>1; if(mid==index) {SCI++; Break; } Else if(mid<index) {SCI++; L=mid+1; } Else{SCI++; R=mid-1; }} stime=sci*s; if(stime>gtime) cout<<1<<Endl; Elsecout<<2<<Endl; } return 0;}
If you have any questions, please leave a message
Who'll Win?