結果

問題 No.800 四平方定理
ユーザー Yoshinari TakaokaYoshinari Takaoka
提出日時 2019-03-18 00:38:22
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 556 bytes
コンパイル時間 1,195 ms
コンパイル使用メモリ 144,880 KB
実行使用メモリ 65,508 KB
最終ジャッジ日時 2023-09-22 16:16:38
合計ジャッジ時間 4,001 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 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,388 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 4 ms
4,556 KB
testcase_10 AC 36 ms
34,208 KB
testcase_11 AC 41 ms
38,088 KB
testcase_12 AC 41 ms
37,344 KB
testcase_13 AC 36 ms
35,560 KB
testcase_14 AC 40 ms
37,860 KB
testcase_15 AC 40 ms
37,764 KB
testcase_16 AC 39 ms
38,052 KB
testcase_17 AC 41 ms
38,232 KB
testcase_18 AC 44 ms
38,036 KB
testcase_19 AC 45 ms
38,128 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 47 ms
38,072 KB
testcase_23 AC 92 ms
65,464 KB
testcase_24 AC 85 ms
65,416 KB
testcase_25 AC 91 ms
65,232 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 RE -
testcase_28 AC 84 ms
65,260 KB
testcase_29 AC 86 ms
65,472 KB
testcase_30 AC 83 ms
65,216 KB
testcase_31 AC 78 ms
60,892 KB
testcase_32 AC 84 ms
65,508 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, 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