where n is ?? On Fri, Jun 17, 2011 at 3:23 PM, Arpit Sood <[email protected]> wrote:
> i have got AC with O(n) > > On Fri, Jun 17, 2011 at 2:59 PM, sunny agrawal <[email protected]>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 <[email protected]> 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 [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> 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 [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
