the problem is same in my code?
@harshil21
Please help me understand what’s wrong with this code
https://www.codechef.com/viewsolution/33043882
I’ve tried all the test cases you’ve mentioned in the comments, all are working
Its giving the correct answer
Finally after lot many efforts optimised it to O(bits) solution and a very fast one.
I got it .
There was some problem with the test cases as i have to use unsigned long instead of unsigned long long
Can anyone please explain what exactly are we doing? And also why can’t we directly use ‘for’ loop for this?
My solution:
https://www.codechef.com/viewsolution/32653676
Because the test files of subtask 2 contains a test case where the resulting product may overflow and overflow of long long is diff. from overflow of unsigned long long.
@pulkit_mittal so long long, even when overflowed, gives right answer in comparison? that’s funny. Can you help me figure out why rest of test cases are wrong?
Most probably the solution which was used for generating ans uses long long.
No
https://www.codechef.com/viewsolution/33049526
This solution is giving Runtime Error(SIGSEV)
Can anybody help where i am going wrong
Why i is taken as 42 in the code?
Why is in tester’s solution the he is shifting till only 42…but not 64
because the max no of bits a long can have in this case is upto 40… i.e(2^40>10^12)
(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)
you are saying that you want to iterate over the whole range…that range is 0 to 10^12…of course it will give TLE as we can have at max 10^8 operations in a sec generally.
Not iterating but …2^64 would have 64 bits right?
yes bro