結果

問題 No.864 四方演算
ユーザー Lily89164763Lily89164763
提出日時 2020-07-13 18:53:14
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 68 ms / 1,000 ms
コード長 2,349 bytes
コンパイル時間 4,062 ms
コンパイル使用メモリ 104,112 KB
実行使用メモリ 24,716 KB
最終ジャッジ日時 2023-08-07 18:10:22
合計ジャッジ時間 6,022 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,712 KB
testcase_01 AC 68 ms
22,692 KB
testcase_02 AC 65 ms
24,716 KB
testcase_03 AC 66 ms
20,640 KB
testcase_04 AC 67 ms
20,608 KB
testcase_05 AC 64 ms
20,616 KB
testcase_06 AC 67 ms
20,692 KB
testcase_07 AC 65 ms
20,748 KB
testcase_08 AC 64 ms
20,744 KB
testcase_09 AC 61 ms
20,724 KB
testcase_10 AC 60 ms
22,644 KB
testcase_11 AC 59 ms
20,744 KB
testcase_12 AC 64 ms
20,800 KB
testcase_13 AC 62 ms
20,740 KB
testcase_14 AC 59 ms
20,724 KB
testcase_15 AC 68 ms
20,680 KB
testcase_16 AC 65 ms
20,616 KB
testcase_17 AC 67 ms
22,760 KB
testcase_18 AC 65 ms
20,768 KB
testcase_19 AC 63 ms
20,748 KB
testcase_20 AC 67 ms
22,688 KB
testcase_21 AC 65 ms
20,600 KB
testcase_22 AC 65 ms
22,796 KB
testcase_23 AC 57 ms
20,796 KB
testcase_24 AC 64 ms
22,744 KB
testcase_25 AC 60 ms
20,804 KB
testcase_26 AC 64 ms
20,696 KB
testcase_27 AC 57 ms
20,676 KB
testcase_28 AC 56 ms
22,772 KB
testcase_29 AC 56 ms
20,760 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        long n = sc.NextLong();
        long k = sc.NextLong();
        long ans = 0;
        for (long ac = 1; ac * ac <= k; ac++)
        {
            if (k % ac != 0) continue;
            long bd = k / ac;

            // ac,bdを[1,N]の2数の和にする
            // Console.WriteLine($"{ac} {C(ac, n)} {bd} {C(bd, n)}");
            ans += C(ac, n) * C(bd, n) * (ac == bd ? 1 : 2);
        }

        Console.WriteLine(ans);
    }

    long C(long sum, long n)
    {
        if (sum > 2 * n) return 0;
        if (sum <= n + 1) return sum - 1;
        return 2 * n - sum + 1;
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}
0