Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- int p = int.Parse(Console.ReadLine());
- // (P ^ P̃) & P̈
- int pReversed = 0;
- int pTemp = p;
- while (pTemp != 0)
- {
- pReversed <<= 1;
- pReversed |= (pTemp & 1);
- pTemp >>= 1;
- }
- int answer = (p ^ ~p) & pReversed;
- Console.WriteLine(answer);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment