結果

問題 No.800 四平方定理
ユーザー bluemeganebluemegane
提出日時 2021-04-29 14:20:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 1,049 ms
コンパイル使用メモリ 61,620 KB
実行使用メモリ 74,684 KB
最終ジャッジ日時 2023-09-22 22:56:14
合計ジャッジ時間 6,577 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,756 KB
testcase_01 AC 57 ms
21,076 KB
testcase_02 AC 58 ms
20,832 KB
testcase_03 AC 59 ms
20,888 KB
testcase_04 AC 57 ms
22,864 KB
testcase_05 AC 57 ms
20,872 KB
testcase_06 AC 58 ms
23,232 KB
testcase_07 AC 59 ms
23,324 KB
testcase_08 AC 59 ms
21,612 KB
testcase_09 AC 57 ms
19,032 KB
testcase_10 AC 130 ms
44,956 KB
testcase_11 AC 136 ms
51,228 KB
testcase_12 AC 141 ms
49,952 KB
testcase_13 AC 124 ms
44,568 KB
testcase_14 AC 128 ms
52,256 KB
testcase_15 AC 142 ms
50,152 KB
testcase_16 AC 128 ms
48,440 KB
testcase_17 AC 127 ms
46,404 KB
testcase_18 AC 148 ms
54,268 KB
testcase_19 AC 150 ms
52,280 KB
testcase_20 AC 56 ms
22,772 KB
testcase_21 AC 55 ms
20,708 KB
testcase_22 AC 148 ms
52,348 KB
testcase_23 AC 221 ms
74,684 KB
testcase_24 AC 197 ms
70,808 KB
testcase_25 AC 215 ms
74,532 KB
testcase_26 AC 57 ms
22,736 KB
testcase_27 AC 56 ms
20,876 KB
testcase_28 AC 195 ms
70,704 KB
testcase_29 AC 208 ms
72,612 KB
testcase_30 AC 197 ms
68,512 KB
testcase_31 AC 182 ms
67,340 KB
testcase_32 AC 200 ms
71,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var d = int.Parse(line[1]);
        getAns(n, d);
    }
    static void getAns(int n, int d)
    {
        var a = new int[n * n * 2 + 1];
        var b = new int[n * n + d + 1];
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
            {
                a[i * i + j * j]++;
                var t = i * i - j * j + d;
                if (t >= 1) b[t]++;
            }
        var imax = Min(a.Length, b.Length);
        var ans = 0L;
        for (int i = 1; i < imax; i++) ans += a[i] * b[i];
        Console.WriteLine(ans);
    }
}
0