lol, i mean in linear time....

On Fri, Jun 17, 2011 at 3:27 PM, sunny agrawal <sunny816.i...@gmail.com>wrote:

> where n is ??
>
> On Fri, Jun 17, 2011 at 3:23 PM, Arpit Sood <soodfi...@gmail.com> wrote:
>
>> i have got AC with O(n)
>>
>> On Fri, Jun 17, 2011 at 2:59 PM, sunny agrawal 
>> <sunny816.i...@gmail.com>wrote:
>>
>>> you need to try something better as limits of A and B are very large :)
>>> you can not run a loop from A to B
>>>
>>> i have not tried it but the logic is there will be many nos which will
>>> give the same value and we dont need to calculate for them all explicitply
>>> :)
>>>
>>>
>>> On Fri, Jun 17, 2011 at 2:52 PM, KK <kunalkapadi...@gmail.com> wrote:
>>>
>>>> To remove all digits left of the rightmost digit one in the binary
>>>> representation of some integer what we need to do is this:
>>>> ans = no & -no
>>>> and this is what is exactly asked in this problem of SPOJ:
>>>> www.spoj.pl/problems/MZVRK/
>>>>
>>>>
>>>> #include<iostream>
>>>> using namespace std;
>>>> int main()
>>>> {
>>>>    unsigned long long int a, b, sum;
>>>>    while(scanf("%lld%lld", &a, &b) != EOF)
>>>>    {
>>>>              sum = 0;
>>>>              while(a != (b+1))
>>>>              {
>>>>                      sum += (a & -a);
>>>>                      a++;
>>>>              }
>>>>              printf("%lld\n", sum);
>>>>    }
>>>>    return 0;
>>>> }
>>>>
>>>> Its giving TLE on some 10th case...
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>>
>>>
>>>
>>> --
>>> Sunny Aggrawal
>>> B-Tech IV year,CSI
>>> Indian Institute Of Technology,Roorkee
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Regards,
>> Arpit Sood
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards,
Arpit Sood

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to