Guest User

Wiggle Wiggle

a guest
Dec 18th, 2015
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace wiggle
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] input = Console.ReadLine().Split(' ');
  14.             List<long> result = new List<long>();
  15.             for (int i = 0; i < input.Length - 1; i += 2)
  16.             {
  17.                 long num1 = long.Parse(input[i]);
  18.                 long num2 = long.Parse(input[i + 1]);
  19.                 for (int j = 0; j <= 62; j += 2)
  20.                 {
  21.                     long currentnum1bit = ((num1 >> j) & 1L);
  22.                     long currentnum2bit = (num2 >> j) & 1L;
  23.                     if (currentnum1bit == 0)
  24.                     {
  25.                         num2 = num2 & ~(1L<< j);
  26.                     }
  27.                     if (currentnum1bit == 1)
  28.                     {
  29.                         num2 = num2 | (1L << j);
  30.                     }
  31.                     if (currentnum2bit == 0)
  32.                     {
  33.                         num1 = num1 & ~(1L << j);
  34.                     }
  35.                     if (currentnum2bit == 1)
  36.                     {
  37.                         num1 = num1 | (1L << j);
  38.                     }
  39.                 }
  40.                 long finalfirstnum = ~(num1 | (1L << 63));
  41.                 long finalsecondnum = ~(num2 | (1L << 63));
  42.                 result.Add(finalfirstnum);
  43.                 result.Add(finalsecondnum);
  44.             }
  45.             foreach(var num in result)
  46.             {
  47.                 Console.WriteLine((ulong)num + " " + Convert.ToString(num,2).PadLeft(63,'0'));
  48.             }
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment