Using System; using System. collections. generic; using System. linq; using System. text; using System. numerics; using System. globalization; using System. diagnostics; namespace ConsoleApplication11 {class Program {static int [] howmustics = new int,,, 2 ,,,, 7, 4, 5, 6, 6, 6, 6, 7, 5, 6, 7, 7, 8}; static void Main (string [] args) {Stopwatch SW = New Stopwatch (); SW. start (); BigInteger B = new BigInteger (234235436457658); BigInteger A = (BigInteger. one <3999) + B; Tuple <int, int> Sim = MatchDegree (A, B); SW. stop (); Console. writeLine ("Same number" + Sim. item1); Console. writeLine ("Total" + B. toByteArray (). length * 8); Console. writeLine ("offset" + Sim. item2); Console. writeLine ("milliseconds" + SW. elapsedMilliseconds); Console. read ();} public static Tuple <int, Int> MatchDegree (BigInteger A, BigInteger B) {Tuple <int, int> max = new Tuple <int, int> (0, 0); int a =. toByteArray (). length; B = B <a; int offset = 0; while (B> BigInteger. one) {B >>= 1; offset ++; int count = MatchDegree (~ (A ^ B); if (count> max. item1) {max = new Tuple <int, int> (count, offset) ;}return max ;}public static int MatchDegree (BigInteger A) {byte [] B =. toByteArray (); int count = 0; for (int I = 0; I <B. length; I ++) {count + = howmuw.[ B [I];} return count ;} // determine the number of public static int MatchDegree (ulong u) {u = (u & 0x5555555555555555) + (u> 1) in a ulong number) & 0x5555555555555555); u = (u & 0x3333333333333333) + (u> 2) & 0x3333333333333333); u = (u & 0x0f0f0f0f0f) + (u> 4) & 0x0f0f0f0f0f0f); u = (u & 0x00FF00FF00FF00FF) + (u> 8) & 0x00FF00FF00FF00FF); u = (u & 0x0000FFFF0000FFFF) + (u> 16) & 0x0000FFFF0000FFFF); u = (u & 0x000000000000ffffffff) + (u> 32) & 0x00000000FFFFFFFF); return Convert. toInt32 (u);} private static string DisplayInBinary (BigInteger number) {byte [] bytes = number. toByteArray (); string binaryString = string. empty; foreach (byte byteValue in bytes) {string byteString = Convert. toString (byteValue, 2 ). trim (); binaryString + = byteString. insert (0, new string ('0', 8-byteString. length) ;}return binaryString ;}}}