結果

問題 No.800 四平方定理
ユーザー mikianaaamikianaaa
提出日時 2020-10-15 21:24:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 3,302 ms
コンパイル使用メモリ 166,228 KB
実行使用メモリ 67,036 KB
最終ジャッジ日時 2023-09-28 01:20:20
合計ジャッジ時間 6,222 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,584 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,500 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,900 KB
testcase_07 AC 2 ms
4,504 KB
testcase_08 AC 2 ms
4,744 KB
testcase_09 AC 2 ms
4,556 KB
testcase_10 AC 32 ms
36,132 KB
testcase_11 AC 34 ms
38,292 KB
testcase_12 AC 37 ms
38,124 KB
testcase_13 AC 33 ms
36,120 KB
testcase_14 AC 34 ms
38,148 KB
testcase_15 AC 39 ms
38,192 KB
testcase_16 AC 35 ms
40,168 KB
testcase_17 AC 36 ms
40,196 KB
testcase_18 AC 40 ms
40,184 KB
testcase_19 AC 40 ms
40,224 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 40 ms
40,224 KB
testcase_23 AC 80 ms
66,820 KB
testcase_24 AC 71 ms
67,036 KB
testcase_25 AC 82 ms
66,904 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 70 ms
66,924 KB
testcase_29 AC 77 ms
66,948 KB
testcase_30 AC 72 ms
66,900 KB
testcase_31 AC 66 ms
62,744 KB
testcase_32 AC 76 ms
66,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

ll cnt[100000000] = {0};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, D;
    cin >> N >> D;
    ll ans = 0;
    map<ll, ll> ma;

    for (int x = 1; x <= N; x++) {
        for (int y = 1; y <= N; y++) {
            ll tmp = x * x + y * y;
            if (tmp > 100000000)
                continue;
            cnt[tmp]++;
        }
    }

    for (int w = 1; w <= N; w++) {
        for (int z = 1; z <= N; z++) {
            int tmp = w * w - z * z + D;
            if (tmp >= 0 && cnt[tmp] > 0)
                ans += cnt[tmp];
        }
    }

    cout << ans << endl;
}
0