結果

問題 No.800 四平方定理
ユーザー YamaKasaYamaKasa
提出日時 2020-11-18 23:53:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 1,513 ms
コンパイル使用メモリ 163,652 KB
実行使用メモリ 34,796 KB
最終ジャッジ日時 2023-09-30 15:18:40
合計ジャッジ時間 3,547 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 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 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 22 ms
19,104 KB
testcase_11 AC 26 ms
21,024 KB
testcase_12 AC 26 ms
20,464 KB
testcase_13 AC 19 ms
19,792 KB
testcase_14 AC 22 ms
20,792 KB
testcase_15 AC 25 ms
20,636 KB
testcase_16 AC 25 ms
20,920 KB
testcase_17 AC 23 ms
20,912 KB
testcase_18 AC 28 ms
20,964 KB
testcase_19 AC 27 ms
20,928 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 26 ms
20,984 KB
testcase_23 AC 65 ms
34,604 KB
testcase_24 AC 54 ms
34,796 KB
testcase_25 AC 65 ms
34,792 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 54 ms
34,416 KB
testcase_29 AC 62 ms
34,672 KB
testcase_30 AC 56 ms
34,636 KB
testcase_31 AC 53 ms
32,540 KB
testcase_32 AC 55 ms
34,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int N, D;
    cin >> N >> D;
    int n = 2 * N * N + 1;
    int d[n]{};
    for (int x = 1; x <= N; x++) {
        for (int y = 1; y <= N; y++) {
            d[x * x + y * y]++;
        }
    }
    int cnt = 0;
    for (int z = 1; z <= N; z++) {
        for (int w = 1; w <= N; w++) {
            int t = w * w - z * z + D;
            if (t >= 0 && t <= n - 1) {
                cnt += d[t];
            }
        }
    }
    cout << cnt << "\n";
    return 0;
}
0