結果

問題 No.800 四平方定理
ユーザー tktk_snsntktk_snsn
提出日時 2021-04-27 23:00:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 696 bytes
コンパイル時間 1,222 ms
コンパイル使用メモリ 82,792 KB
実行使用メモリ 38,416 KB
最終ジャッジ日時 2023-09-20 23:11:02
合計ジャッジ時間 6,957 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,524 KB
testcase_01 AC 2 ms
5,668 KB
testcase_02 AC 3 ms
5,564 KB
testcase_03 AC 2 ms
5,584 KB
testcase_04 AC 2 ms
5,696 KB
testcase_05 AC 2 ms
5,656 KB
testcase_06 AC 3 ms
5,952 KB
testcase_07 AC 3 ms
6,024 KB
testcase_08 AC 3 ms
6,072 KB
testcase_09 AC 2 ms
5,708 KB
testcase_10 AC 38 ms
31,964 KB
testcase_11 AC 40 ms
34,056 KB
testcase_12 AC 44 ms
34,132 KB
testcase_13 AC 33 ms
29,912 KB
testcase_14 AC 36 ms
34,192 KB
testcase_15 AC 45 ms
34,068 KB
testcase_16 AC 36 ms
34,264 KB
testcase_17 AC 37 ms
34,080 KB
testcase_18 AC 50 ms
38,232 KB
testcase_19 AC 49 ms
38,360 KB
testcase_20 AC 2 ms
5,524 KB
testcase_21 AC 2 ms
5,540 KB
testcase_22 AC 49 ms
38,416 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 2 ms
5,392 KB
testcase_27 AC 4 ms
7,516 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

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