結果

問題 No.800 四平方定理
ユーザー xuzijian629xuzijian629
提出日時 2019-03-17 21:51:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 2,015 ms
コンパイル使用メモリ 199,424 KB
実行使用メモリ 34,440 KB
最終ジャッジ日時 2023-09-22 05:06:57
合計ジャッジ時間 4,306 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 24 ms
19,676 KB
testcase_11 AC 28 ms
21,852 KB
testcase_12 AC 27 ms
21,920 KB
testcase_13 AC 25 ms
19,732 KB
testcase_14 AC 26 ms
22,028 KB
testcase_15 AC 27 ms
21,740 KB
testcase_16 AC 25 ms
21,784 KB
testcase_17 AC 29 ms
21,836 KB
testcase_18 AC 31 ms
21,792 KB
testcase_19 AC 32 ms
21,788 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 31 ms
21,792 KB
testcase_23 AC 71 ms
34,244 KB
testcase_24 AC 64 ms
34,272 KB
testcase_25 AC 68 ms
34,292 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 66 ms
34,136 KB
testcase_29 AC 68 ms
34,208 KB
testcase_30 AC 66 ms
34,440 KB
testcase_31 AC 54 ms
34,024 KB
testcase_32 AC 63 ms
34,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

int cnt[8000001];

int main() {
    int n, d;
    cin >> n >> d;
    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 (r - z * z >= 0)
            ans += cnt[r - z * z];
        }
    }
    cout << ans << endl;
}
0