Sorry .. I hit send too soon :P
#include<iostream>
#include<math.h>
using namespace std;
double log(double a, double b)
{
return log(a)/log(b);
}
int main()
{
double L,P,C;
int T,t;
cin>>T;
for(t=1;t<=T;t++)
{
cin>>L>>P>>C;
double a = log(log(P/L,C),2);
int a_int = a;
while(a_int < a) a_int++;
a_int = max(a_int, 0);
cout<<"Case #"<<t<<": "<<a_int<<endl;
}
}
On 23 May 2010 18:24, Bharath Raghavendran <[email protected]> wrote:
> Here is the mathematical formula :
> double a = log(log(P/L,C),2);
> int a_int = a;
> while(a_int < a) a_int++;
> a_int = max(a_int, 0);
>
>
> On 23 May 2010 17:49, Bharath Raghavendran <[email protected]> wrote:
>
>> You are trying to find a value of a between L and P such that u r sure
>> that a contestants can access at a time but C*a contestants cannot.
>>
>> Its basically a binary search for a satisfying element between L and P
>> with a small modification that instead of taking (L+P)/2 each time, go for
>> their geometric mean. This will maintain the ratio of first and last between
>> the two halves and hence will be most optimal.
>>
>>
>> On 23 May 2010 17:40, Saurabh Aggarwal <[email protected]> wrote:
>>
>>> Hi Guys,
>>>
>>> Could anyone please explain the logic behind the "Load Testing" problem
>>> ?
>>> From the solutions I gathered that they have found the number of bits in
>>> X, where
>>>
>>> L * (C^X) > P
>>>
>>> But couldn't understand why this was done ?
>>>
>>> Thanks.
>>>
>>> --
>>> Regards,
>>> Saurabh Aggarwal
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "google-codejam" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<google-code%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-code?hl=en.
>>>
>>
>>
>
--
You received this message because you are subscribed to the Google Groups
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-code?hl=en.