Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Numerics;
- static class bitove
- {
- public static void Main()
- {
- long x = long.Parse(Console.ReadLine());
- string s =Convert.ToString(x,2);
- //Console.WriteLine(s);
- ulong[] bits = s.Select(c => ulong.Parse(c.ToString())).ToArray();
- for (int i = 0; i < bits.Length-2; i++)
- {
- if ((bits[i]==bits[i+1])&(bits[i+1]==bits[i+2]))
- {
- bits[i] ^= 1;
- bits[i+1] ^= 1;
- bits[i+2] ^= 1;
- i += 2;
- }
- }
- List<ulong> output = new List<ulong>();
- foreach (var bit in bits)
- {
- output.Add(bit);
- }
- //for (int i = 0; i < output.Count; i++)
- // {
- // Console.Write(output[i]);
- // }
- string[] result = output.Select(c => c.ToString()).ToArray();
- string result2 = string.Join("", result);
- //Console.WriteLine();
- Console.WriteLine(Convert.ToUInt64(result2, 2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement