結果

問題 No.800 四平方定理
ユーザー nebukuro09nebukuro09
提出日時 2019-03-17 21:26:13
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 1,261 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 683 ms
コンパイル使用メモリ 101,096 KB
実行使用メモリ 209,660 KB
最終ジャッジ日時 2023-09-03 23:45:21
合計ジャッジ時間 17,874 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,376 KB
testcase_01 AC 12 ms
5,928 KB
testcase_02 AC 9 ms
6,952 KB
testcase_03 AC 10 ms
5,924 KB
testcase_04 AC 9 ms
5,928 KB
testcase_05 AC 10 ms
6,196 KB
testcase_06 AC 13 ms
6,160 KB
testcase_07 AC 11 ms
6,980 KB
testcase_08 AC 13 ms
6,152 KB
testcase_09 AC 12 ms
5,924 KB
testcase_10 AC 494 ms
62,200 KB
testcase_11 AC 554 ms
64,912 KB
testcase_12 AC 537 ms
65,564 KB
testcase_13 AC 501 ms
62,544 KB
testcase_14 AC 540 ms
62,876 KB
testcase_15 AC 602 ms
63,948 KB
testcase_16 AC 591 ms
64,312 KB
testcase_17 AC 596 ms
63,880 KB
testcase_18 AC 551 ms
67,112 KB
testcase_19 AC 541 ms
64,600 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 550 ms
64,388 KB
testcase_23 AC 1,261 ms
208,572 KB
testcase_24 AC 1,176 ms
207,724 KB
testcase_25 AC 1,248 ms
209,184 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1,139 ms
209,660 KB
testcase_29 AC 1,169 ms
208,300 KB
testcase_30 AC 1,189 ms
207,664 KB
testcase_31 AC 1,077 ms
207,536 KB
testcase_32 AC 1,199 ms
207,992 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