結果

問題 No.800 四平方定理
ユーザー finefine
提出日時 2019-03-17 22:44:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 666 bytes
コンパイル時間 2,364 ms
コンパイル使用メモリ 164,584 KB
実行使用メモリ 66,972 KB
最終ジャッジ日時 2023-09-22 08:48:51
合計ジャッジ時間 5,739 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,784 KB
testcase_01 AC 7 ms
6,072 KB
testcase_02 AC 7 ms
6,100 KB
testcase_03 AC 6 ms
5,944 KB
testcase_04 AC 7 ms
5,852 KB
testcase_05 AC 7 ms
5,920 KB
testcase_06 AC 7 ms
6,216 KB
testcase_07 AC 7 ms
6,524 KB
testcase_08 AC 8 ms
8,300 KB
testcase_09 AC 7 ms
6,216 KB
testcase_10 AC 34 ms
56,584 KB
testcase_11 AC 39 ms
60,872 KB
testcase_12 AC 38 ms
60,696 KB
testcase_13 AC 33 ms
52,500 KB
testcase_14 AC 33 ms
58,644 KB
testcase_15 AC 39 ms
60,876 KB
testcase_16 AC 37 ms
58,680 KB
testcase_17 AC 38 ms
58,660 KB
testcase_18 AC 40 ms
66,972 KB
testcase_19 AC 42 ms
66,868 KB
testcase_20 AC 7 ms
5,384 KB
testcase_21 AC 7 ms
5,476 KB
testcase_22 AC 41 ms
66,880 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 7 ms
5,456 KB
testcase_27 AC 7 ms
7,540 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int MAXV = 5000000;

ll cnt1[MAXV + 1], cnt2[MAXV + 1];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    for (int x = 1; x <= n; x++) {
        for (int y = 1; y <= n; y++) {
            cnt1[x * x + y * y]++;
        }
    }

    for (int w = 1; w <= n; w++) {
        int lim = min(n * n, w * w + d);
        for (int z = 1; z * z <= lim; z++) {
            cnt2[d + w * w - z * z]++;
        }
    }

    ll ans = 0;
    for (int i = 0; i <= MAXV; i++) {
        ans += cnt1[i] * cnt2[i];
    }
    cout << ans << endl;
    return 0;
}
0