結果

問題 No.800 四平方定理
ユーザー xuzijian629xuzijian629
提出日時 2019-03-18 11:43:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 454 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 4,936 ms
コンパイル使用メモリ 226,660 KB
実行使用メモリ 150,868 KB
最終ジャッジ日時 2023-09-25 04:17:59
合計ジャッジ時間 10,226 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,332 KB
testcase_01 AC 7 ms
5,276 KB
testcase_02 AC 7 ms
5,276 KB
testcase_03 AC 7 ms
5,268 KB
testcase_04 AC 7 ms
5,368 KB
testcase_05 AC 7 ms
5,276 KB
testcase_06 AC 11 ms
7,916 KB
testcase_07 AC 7 ms
5,232 KB
testcase_08 AC 12 ms
7,696 KB
testcase_09 AC 8 ms
5,332 KB
testcase_10 AC 190 ms
76,996 KB
testcase_11 AC 198 ms
76,844 KB
testcase_12 AC 200 ms
77,068 KB
testcase_13 AC 196 ms
76,956 KB
testcase_14 AC 208 ms
76,960 KB
testcase_15 AC 206 ms
76,996 KB
testcase_16 AC 214 ms
76,996 KB
testcase_17 AC 212 ms
76,932 KB
testcase_18 AC 201 ms
76,908 KB
testcase_19 AC 203 ms
76,956 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 206 ms
76,972 KB
testcase_23 AC 454 ms
150,616 KB
testcase_24 AC 429 ms
150,560 KB
testcase_25 AC 439 ms
150,660 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 424 ms
150,740 KB
testcase_29 AC 419 ms
150,572 KB
testcase_30 AC 407 ms
150,620 KB
testcase_31 AC 383 ms
150,868 KB
testcase_32 AC 405 ms
150,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

int main() {
    int n, d;
    cin >> n >> d;
    gp_hash_table<int, int> cnt;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cnt[i * i + j * j]++;
        }
    }

    int ans = 0;
    for (int w = 1; w <= n; w++) {
        int r = w * w + d;
        for (int z = 1; z <= n; z++) {
            if (cnt[r - z * z])
            ans += cnt[r - z * z];
        }
    }
    cout << ans << endl;
}
0