結果

問題 No.800 四平方定理
ユーザー SuikabaSuikaba
提出日時 2019-03-17 21:28:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 472 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 207,024 KB
実行使用メモリ 139,540 KB
最終ジャッジ日時 2023-09-22 03:48:01
合計ジャッジ時間 23,315 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
9,356 KB
testcase_01 AC 17 ms
5,864 KB
testcase_02 AC 12 ms
4,936 KB
testcase_03 AC 13 ms
5,008 KB
testcase_04 AC 11 ms
4,976 KB
testcase_05 AC 12 ms
5,308 KB
testcase_06 AC 21 ms
6,720 KB
testcase_07 AC 15 ms
5,748 KB
testcase_08 AC 21 ms
6,716 KB
testcase_09 AC 18 ms
6,328 KB
testcase_10 AC 1,361 ms
69,348 KB
testcase_11 AC 1,600 ms
75,460 KB
testcase_12 AC 1,562 ms
74,268 KB
testcase_13 AC 1,522 ms
71,288 KB
testcase_14 AC 1,609 ms
75,428 KB
testcase_15 AC 1,614 ms
74,860 KB
testcase_16 AC 1,600 ms
75,860 KB
testcase_17 AC 1,600 ms
75,856 KB
testcase_18 AC 1,550 ms
75,464 KB
testcase_19 AC 1,587 ms
75,580 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1,623 ms
75,868 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;

int main() {
    int n, d; cin >> n >> d;
    unordered_map<int, ll> l, r;
    for(int a = 1; a <= n; ++a) {
        for(int b = 1; b <= n; ++b) {
            l[a * a + b * b] += 1;
            r[a * a - b * b + d] += 1;
        }
    }

    ll ans = 0;
    for(auto const& p : l) {
        if(r.count(p.first) == 0) continue;
        ans += p.second * r[p.first];
    }
    
    cout << ans << endl;
}
0