Tom and jerry unique solution

https://codingallinone.blogspot.com/
one of the unique solution for tom and jerry problem.

1 Like

Tom and Jerry Game (EOEO) June Long Challange'20 CodeChef (One Line Solution) - YouTube
One line code

I have also implemented it in the same manner have a look at CodeChef: Practical coding for everyone

my solution can also be implement in one line… but for beginners, this way is more explanatory. and this solution makes people to think on bit level… bit operations are way more faster .

yeah you use same manner … but the code is not DRY. Look at my code… no extra conditions.

isn’t that standaard?

“bit operations are much more fast”
Here you go (AC).

#include <bits/stdc++.h>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--)
	{
		long long ts;
		cin >> ts;
		while (!(ts & 1)) ts >>= 1;
		cout << (ts >> 1) << '\n';
	}
}

Your solution was very hard to understand. I made a new one only with bit operations :wink: