Beispiel #1
0
        static void Main(string[] args)
        {
            var helper       = new CodeJamHelper('B', ProblemType.Large, 0);
            var numTestCases = helper.ReadLineInt32();

            foreach (var caseNum in Enumerable.Range(1, numTestCases))
            {
                var vals       = helper.ReadDoubleArray();
                var C          = vals[0];
                var F          = vals[1];
                var X          = vals[2];
                int n          = 0;
                var expression = C * (1.0 + n + 2.0 / F) - X;
                while (expression < 0)
                {
                    n++;
                    expression = C * (1.0 + n + 2.0 / F) - X;
                }
                // expression has become more than 0 for the minimum n
                var time = X / (2.0 + n * F);
                while (n > 0)
                {
                    n--;
                    time += C / (2.0 + n * F);
                }
                helper.OutputCase(time);
            }
        }
Beispiel #2
0
        // public static Dictionary<string, string> stringToReducedStringMap = new Dictionary<string, string>();
        private static void Main(string[] args)
        {
            var helper       = new CodeJamHelper('C', ProblemType.Small, 2);
            var numTestCases = helper.ReadLineInt32();

            foreach (var caseNum in Enumerable.Range(1, numTestCases))
            {
                var line           = helper.ReadLine();
                var stringToRepeat = helper.ReadLine();
                var items          = line.Split(' ');
                var L = Int32.Parse(items[0]);
                var X = Int32.Parse(items[1]);
                var stringToExamine = string.Empty;
                foreach (int k in Enumerable.Range(1, X))
                {
                    stringToExamine += stringToRepeat;
                }
                if (stringToExamine.Length < 3)
                {
                    helper.OutputCase("NO");
                    continue;
                }

                var done = false;

                if (GetReducedString(stringToExamine) != "-1")
                {
                    helper.OutputCase("NO");
                }
                else
                {
                    // Console.WriteLine("Found -1 ");
                    string firstSubString = "1";
                    for (int n = 0; n < stringToExamine.Length - 2; n++)
                    {
                        firstSubString = Multiply(firstSubString, stringToExamine[n].ToString());
                        if (firstSubString == "i")
                        {
                            string secondSubString = "1";
                            for (int x = n + 1; x < stringToExamine.Length - 1; x++)
                            {
                                secondSubString = Multiply(secondSubString, stringToExamine[x].ToString());
                                if (secondSubString == "j" && GetReducedString(stringToExamine.Substring(x + 1)) == "k")
                                {
                                    done = true;
                                    break;
                                }
                            }
                        }
                    }
                    helper.OutputCase((done) ? "YES" : "NO");
                }
            }
        }
        private static void Main(string[] args)
        {
            var helper       = new CodeJamHelper('B', ProblemType.Small, 0);
            var numTestCases = helper.ReadLineInt32();

            foreach (var caseNum in Enumerable.Range(1, numTestCases))
            {
                var numDiners     = helper.ReadLineInt32();
                var pancakesConf  = helper.ReadLine();
                var pancakesArray = pancakesConf.Split(' ');
                var P             = new List <int>();
                foreach (var pancakeNumStr in pancakesArray)
                {
                    P.Add(Int32.Parse(pancakeNumStr));
                }
                P.Sort();
                helper.OutputCase(MinimumPossibleTime(P));
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            var helper       = new CodeJamHelper('A', ProblemType.Large, 0);
            var numTestCases = helper.ReadLineInt32();

            foreach (var caseNum in Enumerable.Range(1, numTestCases))
            {
                var line             = helper.ReadLine();
                var items            = line.Split(' ');
                var maxShyness       = items[0];
                var shynessCount     = items[1];
                var currShynessLevel = 0;
                var friendCount      = 0;
                var numPplStanding   = 0;
                for (int i = 0; i < shynessCount.Length; i++)
                {
                    currShynessLevel = i;
                    var numPplAtThisLevel = Int32.Parse(shynessCount[i].ToString());
                    if (numPplAtThisLevel != 0)
                    {
                        if (numPplStanding >= currShynessLevel)
                        {
                            // all ppl at this level will stand anyway
                        }
                        else
                        {
                            // we need more ppl to stand .. increment friends
                            friendCount += (currShynessLevel - numPplStanding);
                            // add the additional friends to num ppl standing
                            numPplStanding += (currShynessLevel - numPplStanding);
                            // now these ppl will stand ..increment standing count
                        }
                        numPplStanding += numPplAtThisLevel;
                    }
                }
                helper.OutputCase(friendCount);
            }
        }
        static void Main(string[] args)
        {
            var helper       = new CodeJamHelper('A', ProblemType.Small, 0);
            var numTestCases = helper.ReadLineInt32();

            foreach (var caseNum in Enumerable.Range(1, numTestCases))
            {
                var answer1 = helper.ReadLineInt32();
                var rows    = new List <int[]>();
                rows.Add(helper.ReadInt32Array());
                rows.Add(helper.ReadInt32Array());
                rows.Add(helper.ReadInt32Array());
                rows.Add(helper.ReadInt32Array());
                var answer2 = helper.ReadLineInt32();
                var rowsB   = new List <int[]>();
                rowsB.Add(helper.ReadInt32Array());
                rowsB.Add(helper.ReadInt32Array());
                rowsB.Add(helper.ReadInt32Array());
                rowsB.Add(helper.ReadInt32Array());
                var possibilities1 = rows[answer1 - 1];
                var possibilities2 = rowsB[answer2 - 1];
                var answer         = possibilities1.Intersect(possibilities2).ToList();
                if (answer != null && answer.Count == 1)
                {
                    helper.OutputCase(answer[0]);
                }
                else if (answer.Count > 1)
                {
                    helper.OutputCase("Bad magician!");
                }
                else if (answer.Count == 0)
                {
                    helper.OutputCase("Volunteer cheated!");
                }
            }
        }
        private static void Main()
        {
            var helper       = new CodeJamHelper('D', ProblemType.Small, 0);
            var numTestCases = helper.ReadLineInt32();

            foreach (var caseNum in Enumerable.Range(1, numTestCases))
            {
                var line  = helper.ReadLine();
                var items = line.Split(' ');
                var X     = Int32.Parse(items[0]);
                var R     = Int32.Parse(items[1]);
                var C     = Int32.Parse(items[2]);
                if (X >= 7)
                {
                    helper.OutputCase("RICHARD");
                }
                else if ((R * C) % X != 0)
                {
                    helper.OutputCase("RICHARD");
                }
                else
                {
                    switch (X)
                    {
                    case 1:
                        helper.OutputCase("GABRIEL");
                        break;

                    case 2:
                        helper.OutputCase("GABRIEL");
                        break;

                    case 3:
                        if (R < 2 || C < 2 || (R * C) % (3 * 2) != 0)
                        {
                            helper.OutputCase("RICHARD");
                        }
                        else
                        {
                            helper.OutputCase("GABRIEL");
                        }
                        break;

                    case 4:
                        if (R < 2 || C < 2 || (R * C) % (4 * 3) != 0)
                        {
                            helper.OutputCase("RICHARD");
                        }
                        else
                        {
                            helper.OutputCase("GABRIEL");
                        }
                        break;

                    case 5:
                        if (R < 3 || C < 3 || (R * C) % (5 * 4) != 0)
                        {
                            helper.OutputCase("RICHARD");
                        }
                        else
                        {
                            helper.OutputCase("GABRIEL");
                        }
                        break;

                    case 6:
                        if (R < 4 || C < 4 || (R * C) % (6 * 5) != 0)
                        {
                            helper.OutputCase("RICHARD");
                        }
                        else
                        {
                            helper.OutputCase("GABRIEL");
                        }
                        break;
                    }
                }
            }
        }