Exemplo n.º 1
0
        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                A = line[1];
                B = line[2];
            }
            V = Input.ReadLongArray();
            Array.Sort(V);
            Array.Reverse(V);

            var comb = new PascalCombination(100);

            comb.Run();

            long val  = V[A - 1];
            int  up   = 0;
            int  same = 0;

            for (int i = 0; i < N; i++)
            {
                if (V[i] > val)
                {
                    up++;
                }
                if (V[i] == val)
                {
                    same++;
                }
            }

            {
                long retc = 0;
                int  mn   = A - up;
                int  mx;
                if (up == 0)
                {
                    mx = Math.Min(same, B - up);
                }
                else
                {
                    mx = mn;
                }

                for (int j = mn; j <= mx; j++)
                {
                    Console.Error.WriteLine($"{same} {j}");
                    retc += comb.Combination(same, j);
                }

                double avg = V.Take(A).Sum() * 1.0 / A;
                Console.WriteLine(avg);
                Console.WriteLine(retc);
            }
        }
Exemplo n.º 2
0
        public void Run()
        {
            N = Input.ReadInt();
            S = Console.ReadLine();

            CH = new List <int>();
            CT = new List <int>();

            int prev  = -1;
            int count = 1;

            for (int i = 0; i < N * 2; i++)
            {
                int ch = S[i] - 'a';
                if (prev == ch)
                {
                    count++;
                }
                else
                {
                    if (prev != -1)
                    {
                        CH.Add(prev);
                        CT.Add(count);
                    }
                    prev  = ch;
                    count = 1;
                }

                if (i == 2 * N - 1)
                {
                    CH.Add(prev);
                    CT.Add(count);
                }
            }

            L    = CH.Count;
            COMB = new PascalCombination(40);
            COMB.Run();

            long ret = DFSInit();

            Console.WriteLine(ret);
        }