結果

問題 No.800 四平方定理
コンテスト
ユーザー yasunori
提出日時 2025-02-19 21:02:08
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 555 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,143 ms
コンパイル使用メモリ 331,828 KB
実行使用メモリ 128,384 KB
最終ジャッジ日時 2026-07-03 20:41:13
合計ジャッジ時間 10,030 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main() {
    int n, d; cin >> n >> d;
    int O = 8'000'010;
    vector<int> V(O*2+1, 0);
    vector<int> W(O*2+1, 0);

    for(int x = 1; x <= n; x++) {
        for(int y = 1; y <= n; y++) {
            V[x * x + y * y + O]++;
        }
    }
    for(int z = 1; z <= n; z++) {
        for(int w = 1; w <= n; w++) {
            W[w * w - z * z + d + O]++;
        }
    }

    int ans = 0;
    for(int i = -O; i <= O; i++) {
        ans += V[i+O] * W[i+O];
    }
    cout << ans << endl;
    return 0;
}
0