結果

問題 No.800 四平方定理
ユーザー nebukuro09nebukuro09
提出日時 2019-03-17 21:26:13
言語 D
(dmd 2.099.1)
結果
AC  
実行時間 1,103 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 2,343 ms
使用メモリ 207,488 KB
最終ジャッジ日時 2023-02-11 03:52:29
合計ジャッジ時間 16,133 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 7 ms
4,904 KB
testcase_01 AC 11 ms
6,944 KB
testcase_02 AC 9 ms
6,952 KB
testcase_03 AC 8 ms
6,948 KB
testcase_04 AC 8 ms
6,392 KB
testcase_05 AC 10 ms
6,948 KB
testcase_06 AC 13 ms
6,956 KB
testcase_07 AC 11 ms
6,952 KB
testcase_08 AC 12 ms
6,952 KB
testcase_09 AC 12 ms
6,608 KB
testcase_10 AC 356 ms
60,504 KB
testcase_11 AC 378 ms
62,256 KB
testcase_12 AC 371 ms
61,972 KB
testcase_13 AC 358 ms
61,220 KB
testcase_14 AC 375 ms
62,184 KB
testcase_15 AC 382 ms
62,236 KB
testcase_16 AC 383 ms
62,500 KB
testcase_17 AC 388 ms
62,228 KB
testcase_18 AC 390 ms
62,340 KB
testcase_19 AC 375 ms
62,188 KB
testcase_20 AC 1 ms
4,904 KB
testcase_21 AC 1 ms
4,904 KB
testcase_22 AC 395 ms
62,332 KB
testcase_23 AC 1,015 ms
207,460 KB
testcase_24 AC 973 ms
207,384 KB
testcase_25 AC 1,009 ms
207,284 KB
testcase_26 AC 1 ms
4,904 KB
testcase_27 AC 1 ms
4,904 KB
testcase_28 AC 924 ms
207,468 KB
testcase_29 AC 953 ms
207,476 KB
testcase_30 AC 1,002 ms
207,488 KB
testcase_31 AC 1,103 ms
205,180 KB
testcase_32 AC 1,064 ms
207,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0];
    auto D = s[1];

    long[long] cnt;
    foreach (z; 1..N+1) foreach (w; 1..N+1) cnt[z*z-w*w] += 1;
    long ans = 0;

    foreach (x; 1..N+1) {
        foreach (y; 1..N+1) {
            if (D-x*x-y*y in cnt) {
                ans += cnt[D-x*x-y*y];
            }
        }
    }

    ans.writeln;
}
0