Comments
0

I thought I was the only one who got this issue. Use log2l instead of log2. It works because it log2l has more precision. log2 is rounding things off.

if(floor(log2(b)) != ceil(log2(b))
// Try this test case
1
576460752303423483 1
ans:-1 yours will be 20).
0

suppose a>b. Then if a/b is a power of 2 then only answers exist. Suppose a=48, b=3. then a/b=16. log(a,b)=4 and ans = (4/3 +1)(here pow(2,8) and pow(2,2) are used). if a=96, b=3. ans(4/3+2)(here pow(2,8) and pow(2,4) are used). So the OP logic would work for that. The problem is how he is taking log(even I got WA for the same reason).

0

I had the same issue (same test case) and could not find the issue during the contest. The problem is with how you are calculating log. Taking log and then typecasting it into long double will not work(since you have a log in a long double). You should use log2l instead. c++ reference

ceil(20/18) is 2

On McDic → Codeforces Round #633, 7 years ago
0

Ok

0

I tried solving div2C by iterating through the array, whenever a[i]>a[i+1] I added to all j=i+1 and j<n lowest power of 2 possible to make it a[i]<=a[i+1]. Lowest power was calculated using a vector of powers of 2. But it does not work, and I am unable to find out why. Can anyone help?

On McDic → Codeforces Round #633, 7 years ago
0

No. Try this case. 1 2 3 4 4 5 your answer --> 5 4 4 3 2 1--> difference= 1 0 1 1 1(Does not follow the condition)

-7

Lightning-fast system testing

non-ascending means it is not strictly descending. 5,4,3,2,1 --> strictly descending 5,4,3,3,2 --> non -ascending (not strictly descending)