結果

問題 No.800 四平方定理
ユーザー null_mnnull_mn
提出日時 2019-03-20 20:40:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,776 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 1,722 ms
コンパイル使用メモリ 173,916 KB
実行使用メモリ 84,324 KB
最終ジャッジ日時 2023-10-19 04:33:04
合計ジャッジ時間 25,155 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,388 KB
testcase_01 AC 21 ms
5,436 KB
testcase_02 AC 15 ms
4,652 KB
testcase_03 AC 17 ms
4,652 KB
testcase_04 AC 15 ms
4,388 KB
testcase_05 AC 17 ms
4,652 KB
testcase_06 AC 24 ms
5,700 KB
testcase_07 AC 16 ms
5,436 KB
testcase_08 AC 12 ms
5,700 KB
testcase_09 AC 22 ms
5,436 KB
testcase_10 AC 779 ms
44,092 KB
testcase_11 AC 797 ms
72,060 KB
testcase_12 AC 838 ms
72,020 KB
testcase_13 AC 677 ms
44,620 KB
testcase_14 AC 737 ms
72,020 KB
testcase_15 AC 854 ms
72,020 KB
testcase_16 AC 746 ms
72,020 KB
testcase_17 AC 750 ms
72,020 KB
testcase_18 AC 933 ms
72,020 KB
testcase_19 AC 947 ms
72,020 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 957 ms
72,020 KB
testcase_23 AC 1,776 ms
84,324 KB
testcase_24 AC 1,466 ms
84,324 KB
testcase_25 AC 1,760 ms
84,324 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 1,452 ms
84,324 KB
testcase_29 AC 1,615 ms
84,324 KB
testcase_30 AC 1,448 ms
84,324 KB
testcase_31 AC 1,342 ms
82,220 KB
testcase_32 AC 1,504 ms
84,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int main() {
    ll n, d;
    cin >> n >> d;
    //A(:=xx+yy),B(:=ww-zz+D)の取り得る値を列挙
    vector<ll> A, B;
    for (ll x = 1; x <= n; ++x) {
        for (ll y = 1; y <= n; ++y) {
            A.push_back(x * x + y * y);
        }
    }
    for (ll x = 1; x <= n; ++x) {
        for (ll y = 1; y <= n; ++y) {
            B.push_back(x * x - y * y + d);
        }
    }
    sort(B.begin(), B.end());
    int cnt = 0;
    for (auto a : A) {
        cnt += upper_bound(B.begin(), B.end(), a) - lower_bound(B.begin(), B.end(), a);
    }
    cout << cnt << endl;
    return 0;
}
0