예제 #1
0
        static void Part_Elf()
        {
            int T = File_Manager.ReadInts()[0];

            for (int t = 0; t < T; t++)
            {
                BigInteger[] AB   = File_Manager.ReadBigInts().ToArray();
                double       frac = (double)((double)AB[0] / (double)AB[1]);
                string       bin  = DoubleToBinary(frac, 41);
                Simplify(AB);
                if (AB[1].IsPowerOfTwo && bin.Contains('1'))
                {
                    int n = bin.IndexOf('1') - 1;
                    File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + n);
                }
                else
                {
                    File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + "impossible");
                }
            }
        }