Sad reacts only.
They should have mentioned to use fast IO or endl… just like CodeForces does.
Considering your example, a = 1 and b = 5. Let x = 1/5
Divyam can use the operations ‘add’ or ‘subtract’ in such a way that he can avoid 0 or 1.
If Chef gives him 1/5, then he can add it to make x = 2/5
Suppose again x = 1/5 is given, then he can subtract 1/5 from x and then x becomes 1/5.
So, no matter how many times you give 1/5, Divyam can go from 1/5 to 2/5 and then return to 1/5 again.
Thanks for pointing. I should have check the range for the function.
Got accepted.
Can, anybody tell me how should I run this code in Java. I am getting TLE . In Java we don’t have endl to break the input .!!!
It was basically because of some endl nonsense . It gave accepted by using /n .
Today I realized that endl is worse than logN, really !!!
No is missing
yeah…
lost a lot today bcoz of that stupid thing
same situation bro
yeah
Why are you printing Yes in both case ?
My solution was to see that whether denominator is a power of 2 or not i applied some complicated math to prove that and here is my solution
void solve()
{
unsigned long long int a,b;
cin>>a>>b;
if(b%a==0)
{
b = b/a;
}
if(ceil(log2(b)) == floor(log2(b)))
{
cout<<"Yes\n";
}
else
{
cout<<"No\n";
}
}
I just checked if b is equal to some 2 power x (say) and if it exceeds it(b) then directly outputing no and going to next test case.
For reference : Submission
In addition to printing “No” in the second case you should use fast input output to get AC . Hope it helps!
I had the same check but instead of looping while dividing by 2, I went on to check the number of set bits in the denominator. If it is 1 => the denominator is a power of two. Used __builtin_popcountll() as well as a function for counting set bits. But the result was TLE in both cases.
i guess it was because of endl.
If a number ‘x’ is a power of 2 then the value of (x&(x-1)) == 0 always, I feel this is faster to do.
what happens when A=1 and B=5 then the X=1/5=0.2 then chef can provide Y=4/5=0.8 to make it 1 or Y=1/5=.2 to make it 0. ?
Then the o/p should be yes right?
I have thought that B should be a combination of 2s and 5s and if there is any other prime factors then the o/p should be “No” . Why should 5 not be considered?
I know this it is O(1) time complexity but it was not working for me i don’t know why .It was giving TLE