結果

問題 No.800 四平方定理
ユーザー mine691mine691
提出日時 2019-03-17 23:08:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 1,582 ms
コンパイル使用メモリ 167,408 KB
実行使用メモリ 73,436 KB
最終ジャッジ日時 2023-09-22 09:54:50
合計ジャッジ時間 3,742 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 4 ms
5,016 KB
testcase_08 AC 4 ms
6,532 KB
testcase_09 AC 3 ms
4,500 KB
testcase_10 AC 36 ms
37,548 KB
testcase_11 AC 39 ms
39,704 KB
testcase_12 AC 40 ms
41,740 KB
testcase_13 AC 35 ms
35,592 KB
testcase_14 AC 37 ms
37,808 KB
testcase_15 AC 42 ms
41,972 KB
testcase_16 AC 40 ms
38,128 KB
testcase_17 AC 38 ms
38,080 KB
testcase_18 AC 45 ms
45,872 KB
testcase_19 AC 45 ms
46,308 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 44 ms
46,252 KB
testcase_23 AC 89 ms
73,436 KB
testcase_24 AC 78 ms
65,528 KB
testcase_25 AC 93 ms
73,196 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 4 ms
10,736 KB
testcase_28 AC 81 ms
65,132 KB
testcase_29 AC 83 ms
69,216 KB
testcase_30 AC 80 ms
65,240 KB
testcase_31 AC 73 ms
60,876 KB
testcase_32 AC 80 ms
66,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ll n, d, ans;

int main()
{
    cin >> n >> d;
    vector<ll> X(2 * n * n + d);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            X[i * i + j * j]++;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            int x = i * i - j * j + d;
            if (x > 0)
                ans += X[x];
        }
    }
    cout << ans << endl;
}
0