Hello,
I made two attempts to solve the Cryptopangrams problem. The first Time I used 
Python and the second time C#. I have successfully tested both solutions with 
the sample input. Unfortunately I always get a runtime error when I submit my 
solution. I would be really happy if someone could explain in which cases the 
problem occurs.

///////////////////////////////////////////////////
Python solution:
///////////////////////////////////////////////////

def ComputeGCD(x, y):
    while y != 0:
        x, y = y, x % y
    return x

T = int(input())

for t in range(1, T + 1):
    N, L = [int(s) for s in input().split(" ")]
    Y = [int(s) for s in input().split(" ")]
    X = []
    x1 = ComputeGCD(Y[0], Y[1])
    x0 = Y[0] // x1
    X.append(x0)
    X.append(x1)
    for i in range(2, L + 1):
        X.append(Y[i - 1] // X[i - 1])
    S = sorted(set(X))
    M = [chr(65 + S.index(x)) for x in X]
    print("Case #" + str(t) + ": " + "".join(M))

///////////////////////////////////////////////////
C# solution:
///////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static int[] ConvertToInt32Array(String[] input)
        {
            int[] output = new int[input.Length];
            for(int i = 0; i < input.Length; ++i)
            {
                output[i] = Convert.ToInt32(input[i]);
            }
            return output;
        }

        static BigInteger[] ConvertToBigIntegerArray(String[] input)
        {
            BigInteger[] output = new BigInteger[input.Length];
            for (int i = 0; i < input.Length; ++i)
            {
                output[i] = BigInteger.Parse(input[i]);
            }
            return output;
        }

        static BigInteger FindGCD(BigInteger x, BigInteger y)
        {
            while(!y.IsZero)
            {
                BigInteger tmp = x % y;
                x = y;
                y = tmp;
            }

            return x;
        }

        static void Main(string[] args)
        {
            int T = Convert.ToInt32(Console.ReadLine());

            for(int t = 1; t <= T; ++t)
            {
                int[] P = ConvertToInt32Array(Console.ReadLine().Split(' '));
                int N = P[0];
                int L = P[1];
                BigInteger[] Y = 
ConvertToBigIntegerArray(Console.ReadLine().Split(' '));

                SortedSet<BigInteger> D = new SortedSet<BigInteger>();

                BigInteger x1 = FindGCD(Y[0], Y[1]);
                BigInteger x0 = Y[0] / x1;
                BigInteger[] X = new BigInteger[Y.Length + 1];
                X[0] = x0;
                X[1] = x1;
                D.Add(X[0]);
                D.Add(X[1]);
                for(int i = 2; i < X.Length; ++i)
                {
                    X[i] = Y[i - 1] / X[i - 1];
                    D.Add(X[i]);
                }

                Dictionary<BigInteger, char> map = new Dictionary<BigInteger, 
char>();

                char cur = 'A';
                foreach(BigInteger c in D)
                {
                    map.Add(c, cur);
                    cur++;
                }

                Console.Write("Case #{0}: ", t);
                foreach(BigInteger x in X)
                {
                    Console.Write(map[x]);
                }
                Console.WriteLine();
            }
        }
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/c89c487d-cb95-4edd-85f2-ebf3ff1586c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to