結果

問題 No.800 四平方定理
ユーザー MisterMister
提出日時 2020-08-01 22:44:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 663 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 72,824 KB
実行使用メモリ 65,712 KB
最終ジャッジ日時 2023-09-22 18:51:33
合計ジャッジ時間 3,319 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
65,356 KB
testcase_01 AC 19 ms
65,556 KB
testcase_02 AC 18 ms
65,552 KB
testcase_03 AC 19 ms
65,548 KB
testcase_04 AC 18 ms
65,408 KB
testcase_05 AC 18 ms
65,480 KB
testcase_06 AC 19 ms
65,348 KB
testcase_07 AC 18 ms
65,348 KB
testcase_08 AC 18 ms
65,548 KB
testcase_09 AC 18 ms
65,680 KB
testcase_10 AC 43 ms
65,424 KB
testcase_11 AC 48 ms
65,432 KB
testcase_12 AC 49 ms
65,692 KB
testcase_13 AC 44 ms
65,360 KB
testcase_14 AC 48 ms
65,348 KB
testcase_15 AC 49 ms
65,640 KB
testcase_16 AC 50 ms
65,420 KB
testcase_17 AC 48 ms
65,524 KB
testcase_18 AC 51 ms
65,548 KB
testcase_19 AC 52 ms
65,448 KB
testcase_20 AC 17 ms
65,348 KB
testcase_21 AC 18 ms
65,492 KB
testcase_22 AC 53 ms
65,652 KB
testcase_23 AC 92 ms
65,292 KB
testcase_24 AC 83 ms
65,424 KB
testcase_25 AC 89 ms
65,416 KB
testcase_26 AC 17 ms
65,552 KB
testcase_27 AC 19 ms
65,484 KB
testcase_28 AC 85 ms
65,444 KB
testcase_29 AC 86 ms
65,712 KB
testcase_30 AC 86 ms
65,420 KB
testcase_31 AC 78 ms
65,360 KB
testcase_32 AC 86 ms
65,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using lint = long long;
constexpr int N = 2000 * 2000 * 2;

void solve() {
    int n, d;
    std::cin >> n >> d;

    std::vector<lint> cnt(N + 1, 0);
    for (int x = 1; x <= n; ++x) {
        for (int y = 1; y <= n; ++y) {
            ++cnt[x * x + y * y];
        }
    }

    lint ans = 0;
    for (int z = 1; z <= n; ++z) {
        for (int w = 1; w <= n; ++w) {
            lint rhs = w * w - z * z + d;
            if (0 <= rhs && rhs <= N) ans += cnt[rhs];
        }
    }

    std::cout << ans << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0