結果

問題 No.800 四平方定理
ユーザー xuzijian629
提出日時 2019-03-18 11:43:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 447 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 2,009 ms
コンパイル使用メモリ 222,728 KB
最終ジャッジ日時 2025-01-06 23:25:40
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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