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;
- class Program
- {
- static void Main(string[] args)
- {
- UInt64 input = UInt64.Parse(Console.ReadLine());
- string represent = Convert.ToString((long)input, 2).PadLeft(64, '0');
- //Console.WriteLine(represent);
- char[] representation_array = represent.ToCharArray();
- for (int i = 0; i < representation_array.Length - 2; i++)
- {
- if (representation_array[i] == representation_array[i + 1] && representation_array[i + 1] == representation_array[i + 2])
- {
- if (representation_array[i] == '1')
- {
- representation_array[i] = '0';
- representation_array[i + 1] = '0';
- representation_array[i + 2] = '0';
- }
- else if (representation_array[i] == '0')
- {
- representation_array[i] = '1';
- representation_array[i + 1] = '1';
- representation_array[i + 2] = '1';
- }
- i += 2;
- }
- }
- string temp_repres = new string(representation_array);
- int lenth = temp_repres.Length;
- UInt64 result = Convert.ToUInt64(temp_repres, 2);
- Console.WriteLine(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment