Example #1
0
    public void Solve()
    {
        int N = sc.nextInt();
        var a = sc.ArrayInt(N);

        long ans = 0;
        var  l   = 0;
        var  cnt = 1;

        for (int i = 1; i < N; i++)
        {
            var r = i + 1;
            if (a[i - 1] < a[i] && l <= i && i < r)
            {
                cnt++;
            }
            else
            {
                if (cnt != 1)
                {
                    ans += Combination.Calc(cnt, 2);
                }
                l   = i + 1;
                cnt = 1;
            }
        }
        if (cnt != 1)
        {
            ans += Combination.Calc(cnt, 2);
        }

        WriteLine(ans + N);
    }
Example #2
0
    public void Solve()
    {
        int N  = sc.nextInt();
        var A  = sc.ArrayInt(N);
        var wa = new long[N + 1];

        for (int i = 0; i < N; i++)
        {
            wa[i + 1] = wa[i] + A[i];
        }
        WriteLine(wa.GroupBy(l => l).Where(grp => grp.Count() > 1).Select(grp => Combination.Calc(grp.Count(), 2)).Sum());
    }
Example #3
0
    public void Solve()
    {
        int N = sc.nextInt();
        int M = sc.nextInt();

        long ans   = 1;
        var  prime = PrimeFactors(M).GroupBy(i => i);

        foreach (var g in prime)
        {
            var cnt = g.Count();
            ans *= Combination.Calc(N + cnt - 1, cnt);
            ans %= 1000000007;
        }

        WriteLine(ans);
    }
Example #4
0
        public Double Solve()
        {
            Double      count = 0;
            Combination c     = new Combination(0, 0);

            for (Double n = 1; n <= 100; n++)
            {
                for (Double r = 1; r <= n; r++)
                {
                    c.Set(n, r);
                    if (c.Calc() > LIMIT)
                    {
                        count++;
                    }
                }
            }
            return(count);
        }