Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace BitFlipper
- {
- class Program
- {
- static void Main(string[] args)
- {
- ulong n = ulong.Parse(Console.ReadLine());//594226797558350599;
- ulong mask = 16140901064495857664;
- while (mask >= 7)
- {
- if ((mask & n) == mask || (mask & n) == 0)
- {
- if ((mask & n) == mask)
- {
- n &= (~mask);
- }
- else
- {
- n |= mask;
- }
- mask >>= 3;
- }
- else
- {
- mask >>= 1;
- }
- }
- Console.WriteLine(n);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment