結果

問題 No.800 四平方定理
ユーザー Yoshinari TakaokaYoshinari Takaoka
提出日時 2019-03-18 00:46:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 1,185 ms
コンパイル使用メモリ 145,048 KB
実行使用メモリ 73,344 KB
最終ジャッジ日時 2023-09-22 16:18:00
合計ジャッジ時間 3,550 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,968 KB
testcase_08 AC 4 ms
6,344 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 40 ms
37,536 KB
testcase_11 AC 47 ms
39,652 KB
testcase_12 AC 46 ms
41,672 KB
testcase_13 AC 38 ms
35,396 KB
testcase_14 AC 43 ms
37,836 KB
testcase_15 AC 45 ms
41,624 KB
testcase_16 AC 43 ms
38,120 KB
testcase_17 AC 44 ms
38,104 KB
testcase_18 AC 48 ms
45,768 KB
testcase_19 AC 48 ms
45,760 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 50 ms
46,016 KB
testcase_23 AC 95 ms
73,344 KB
testcase_24 AC 85 ms
65,516 KB
testcase_25 AC 96 ms
73,124 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 5 ms
11,000 KB
testcase_28 AC 86 ms
65,240 KB
testcase_29 AC 91 ms
69,488 KB
testcase_30 AC 83 ms
65,168 KB
testcase_31 AC 78 ms
60,780 KB
testcase_32 AC 88 ms
66,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[]) {
    int N, D;
    cin >> N >> D;

    
    vector<int64_t> arr(N * N + N * N + D, 0);
    for (int x = 1; x <= N; x++) {
        for (int y = 1; y <= N; y++) {
            arr[x * x + y * y]++;
        }
    }

    int64_t ans = 0;
    for (int w = 1; w <= N; w++) {
        for (int z = 1; z <= N; z++) {
            int one = w * w - z * z + D;
            if (one >= 0) {
                ans += arr[one];
            }
        }
    }

    cout << ans << endl;
	return 0;
}
0