コード例 #1
0
        public static void Solve()
        {
            var N = Scanner.Scan <int>();
            var A = Scanner.ScanEnumerable <long>().ToArray();

            MInt.SetMod1000000007();
            var factors = new Dictionary <long, long>();

            for (var i = 0; i < N; i++)
            {
                var prime = new Prime(A[i]);
                foreach (var(key, value) in prime.Factors)
                {
                    if (!factors.ContainsKey(key))
                    {
                        factors[key] = 0;
                    }
                    factors[key] = Math.Max(factors[key], value);
                }
            }

            MInt lcm = 1;

            foreach (var(key, value) in factors)
            {
                lcm *= MInt.Power(key, value);
            }

            MInt answer = 0;

            for (var i = 0; i < N; i++)
            {
                answer += lcm / A[i];
            }

            Console.WriteLine(answer);
        }
コード例 #2
0
ファイル: D.cs プロジェクト: AconCavy/atcoder-csharp
        public static void Solve()
        {
            var S = Scanner.Scan <int>();

            MInt.SetMod1000000007();
            var dp = new MInt[S + 1];

            for (var i = 3; i <= S; i++)
            {
                dp[i] = (MInt)1;
            }
            for (var i = 3; i <= S; i++)
            {
                for (var j = 3; j <= S; j++)
                {
                    if (i - j < 0)
                    {
                        continue;
                    }
                    dp[i] += dp[i - j];
                }
            }
            Console.WriteLine(dp[S]);
        }