結果

問題 No.800 四平方定理
ユーザー バイト
提出日時 2019-03-18 13:19:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 1,481 ms
コンパイル使用メモリ 166,840 KB
実行使用メモリ 34,200 KB
最終ジャッジ日時 2024-07-18 07:23:54
合計ジャッジ時間 2,724 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int cou[(int) 1e7];
int main() {
    int n, d;
    cin >> n >> d;
    for (int i = 1; i < n + 1; i++) {
        for (int j = 1; j < n + 1; j++) {
            cou[i * i + j * j]++;
        }
    }
    int res = 0;
    for (int i = 1; i < n + 1; i++) {
        for (int j = 1; j < n + 1; j++) {
            int v = i * i - j * j + d;
            if (v >= 0)res += cou[v];
        }
    }
    cout << res << endl;
    return 0;
}
0