結果

問題 No.864 四方演算
ユーザー bluemeganebluemegane
提出日時 2021-05-05 19:09:46
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 67 ms / 1,000 ms
コード長 716 bytes
コンパイル時間 1,057 ms
コンパイル使用メモリ 61,208 KB
実行使用メモリ 22,896 KB
最終ジャッジ日時 2023-10-11 13:21:59
合計ジャッジ時間 4,467 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
22,736 KB
testcase_01 AC 67 ms
22,752 KB
testcase_02 AC 64 ms
22,824 KB
testcase_03 AC 65 ms
22,772 KB
testcase_04 AC 66 ms
20,816 KB
testcase_05 AC 63 ms
20,688 KB
testcase_06 AC 66 ms
18,736 KB
testcase_07 AC 65 ms
22,748 KB
testcase_08 AC 63 ms
20,780 KB
testcase_09 AC 60 ms
18,852 KB
testcase_10 AC 60 ms
22,860 KB
testcase_11 AC 57 ms
20,748 KB
testcase_12 AC 64 ms
18,792 KB
testcase_13 AC 61 ms
20,696 KB
testcase_14 AC 58 ms
22,796 KB
testcase_15 AC 67 ms
20,616 KB
testcase_16 AC 66 ms
20,780 KB
testcase_17 AC 67 ms
22,792 KB
testcase_18 AC 65 ms
20,864 KB
testcase_19 AC 64 ms
22,896 KB
testcase_20 AC 67 ms
20,624 KB
testcase_21 AC 64 ms
20,776 KB
testcase_22 AC 63 ms
20,684 KB
testcase_23 AC 58 ms
22,736 KB
testcase_24 AC 64 ms
20,716 KB
testcase_25 AC 60 ms
22,668 KB
testcase_26 AC 64 ms
22,760 KB
testcase_27 AC 56 ms
18,748 KB
testcase_28 AC 55 ms
20,760 KB
testcase_29 AC 56 ms
22,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        var k = long.Parse(Console.ReadLine().Trim());
        getAns(n, k);
    }
    static long calc(long n, long a)
    {
        if (a > 2 * n + 1) return 0;
        if (a <= n) return a - 1;
        return 2 * n - a + 1;
    }
    static void getAns(long n, long k)
    {
        var ans = 0L;
        for (long i = 2; i * i <= k; i++)
        {
            if (k % i == 0)
            {
                var te = calc(n, i);
                if (k / i != i) ans += te * calc(n, k / i) * 2;
                else ans += te * te;
            }
        }
        Console.WriteLine(ans);
    }
}
0