Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace BitFlipper
- {
- class BitFlipper
- {
- public static string ConvertToBinary(ulong value)
- {
- if(value == 0)
- return "0";
- System.Text.StringBuilder b = new System.Text.StringBuilder();
- while(value != 0)
- {
- b.Insert(0 , ( ( value & 1 ) == 1 ) ? '1' : '0');
- value >>= 1;
- }
- return b.ToString();
- }
- static void Main()
- {
- ulong input = ulong.Parse(Console.ReadLine());
- StringBuilder bitsHack = new StringBuilder(ConvertToBinary(input).PadLeft(64,'0'));
- bitsHack.Replace("111" , "222");
- bitsHack.Replace("000" , "111");
- bitsHack.Replace("222" , "000");
- ulong output = Convert.ToUInt64(bitsHack.ToString(),2);
- Console.WriteLine(output);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement