結果

問題 No.800 四平方定理
ユーザー tktk_snsn
提出日時 2021-04-27 23:00:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 696 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 84,456 KB
実行使用メモリ 37,820 KB
最終ジャッジ日時 2024-07-06 17:57:56
合計ジャッジ時間 5,112 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 RE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }

int dpL[5000001], dpR[5000001];

int main() {
    int n, d;
    cin >> n >> d;
    for(int x=1; x<=n; ++x) {
        for (int y=1; y<=n; ++y) {
            dpL[x*x+y*y]++;
            if (x*x-y*y+d>0) dpR[x*x-y*y+d]++;
        }
    }
    int ans = 0, vmax = d + n*n;
    for(int i=0; i<=vmax; ++i) ans += dpR[i]*dpL[i];
    cout << ans << endl;
}
0