Consider the non-zero even number X and the odd number X+1. When computing their beauty score, X gets 1 immediately because it is even. X+1, being odd, does not.
Now divide them both by 2 and round down. You get the same value. For example, if X=10 then floor(10/2)==5 and floor(11/2)==5. Since the second value is the same, the calculation for beauty will be the same for both numbers from that point on. In other words:
if X is even and X>0 then beauty(X) == 1+beauty(X+1).
So if X>0 the answer is always yes.
What about when X==0? If N==1 then the answer is no, beauty(0)==1 and beauty(1)==1.
If N==2 then we have beauty(0)+beauty(2) == 3 compared to beauty(1)+beauty(3) == 2 so the answer is yes. For any value of N larger than 2 the answer is still yes.
So by my logic, the only case where you output NO is when N==1 and X==0. Maybe someone else can prove me wrong. Otherwise your main program could simply be:
1 2 3
|
unsigned long long X,N;
cin >> N >> X;
cout << (X==0 && N==1 ? "NO" : "YES") << '\n';
|
This will still fail for the case where x == 2
64 because unsigned long long is usually 64 bits. I suspect that this is a mistake in the problem. It probably means to restrict x to values less than 2
64