Tom and jerry unique solution
one of the unique solution for tom and jerry problem.

1 Like
One line code

I have also implemented it in the same manner have a look at

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()
	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: