結果

問題 No.800 四平方定理
ユーザー null_mnnull_mn
提出日時 2019-03-20 20:30:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 579 bytes
コンパイル時間 1,631 ms
コンパイル使用メモリ 174,444 KB
実行使用メモリ 116,132 KB
最終ジャッジ日時 2023-10-19 04:32:14
合計ジャッジ時間 6,396 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
9,956 KB
testcase_01 AC 31 ms
7,568 KB
testcase_02 AC 21 ms
6,256 KB
testcase_03 AC 23 ms
6,520 KB
testcase_04 AC 21 ms
6,040 KB
testcase_05 AC 24 ms
6,520 KB
testcase_06 AC 37 ms
8,360 KB
testcase_07 AC 27 ms
7,040 KB
testcase_08 AC 25 ms
8,360 KB
testcase_09 AC 32 ms
7,568 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
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;

int main() {
    ll n, d;
    cin >> n >> d;
    vector<ll> A;
    multiset<ll> B; //A(:=xx+yy),B(:=ww-zz+D)の取り得る値を列挙
    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.insert(x * x - y * y + d);
        }
    }
    int cnt = 0;
    for (auto a : A) {
        cnt += B.count(a);
    }
    cout << cnt << endl;
    return 0;
}
0