Example #1
0
        static void Main(String[] args)
        {
            int n = Cin.NextInt();
            int k = Cin.NextInt();

            int[] t = new int[n];

            for (int i = 0; i < n; i++)
            {
                t[i] = Cin.NextInt();
            }

            int a   = 0;
            int ans = 0;

            for (int i = 0; i < n; i++)
            {
                for (int j = 1; j <= t[i]; j++)
                {
                    int pp = a + (j + k - 1) / k;
                    if (pp == j)
                    {
                        ans++;
                    }
                }
                a += (t[i] + k - 1) / k;
            }
            Cout.Print(ans);
        }
        static void Main(String[] args)
        {
            int n = Cin.NextInt();
            int k = Cin.NextInt();
            int q = Cin.NextInt();

            int[] ns = new int[n];
            for (int i = 0; i < n; i++)
            {
                ns[i] = Cin.NextInt();
            }

            k %= n;
            var res = ns;

            if (k != 0)
            {
                var l = ns.ToList().GetRange(0, n - k).ToArray();
                var r = ns.ToList().GetRange(n - k, k).ToArray();
                res = r.Concat(l).ToArray();
            }

            for (int i = 0; i < q; i++)
            {
                int Q = Cin.NextInt();
                Cout.Print(res[Q]);
            }
        }
Example #3
0
        static void Main(String[] args)
        {
            int T = Cin.NextInt();

            for (int case_ = 0; case_ < T; case_++)
            {
                int   n  = Cin.NextInt();
                int[] ns = new int[n];
                for (int i = 0; i < n; i++)
                {
                    ns[i] = Cin.NextInt();
                }
                int s = 0;
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < i; j++)
                    {
                        if (ns[j] > ns[i])
                        {
                            s++;
                        }
                    }
                }
                Cout.Print(s % 2 == 1? "NO": "YES");
            }
        }
Example #4
0
        static void Main(String[] args)
        {
            r = Cin.NextInt();
            c = Cin.NextInt();
            int n = Cin.NextInt();

            int[,] board = new int[r, c];
            for (int i = 0; i < r; i++)
            {
                var line = Cin.NextToken();
                for (int j = 0; j < c; j++)
                {
                    if (line[j] == '.')
                    {
                        board[i, j] = 0;
                    }
                    else
                    {
                        board[i, j] = 4;
                    }
                }
            }

            int[,,] buffer = new int[r, c, 2];
            for (int i = 0; i < r; i++)
            {
                for (int j = 0; j < c; j++)
                {
                    buffer[i, j, 0] = board[i, j];
                }
            }


            n = (n - 2) % 4 + 2;
            int p = tick(buffer, 0, n);

            for (int i = 0; i < r; i++)
            {
                for (int j = 0; j < c; j++)
                {
                    Cout.Write(buffer[i, j, p] == 0? '.': 'O');
                }
                Cout.Print("");
            }
        }
Example #5
0
        static void Main(String[] args)
        {
            string[] tokens_n = Console.ReadLine().Split(' ');
            int      n        = Convert.ToInt32(tokens_n[0]);
            int      k        = Convert.ToInt32(tokens_n[1]);

            string[] a_temp = Console.ReadLine().Split(' ');
            int[]    a      = Array.ConvertAll(a_temp, Int32.Parse);

            int ans = 0;

            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    if ((a[i] + a[j]) % k == 0)
                    {
                        ans++;
                    }
                }
            }
            Cout.Print(ans);
        }