結果

問題 No.800 四平方定理
ユーザー mine691mine691
提出日時 2019-03-17 23:18:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 69,564 KB
実行使用メモリ 73,284 KB
最終ジャッジ日時 2023-09-22 10:33:53
合計ジャッジ時間 2,742 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 3 ms
4,456 KB
testcase_07 AC 3 ms
4,840 KB
testcase_08 AC 4 ms
6,480 KB
testcase_09 AC 3 ms
4,388 KB
testcase_10 AC 40 ms
37,632 KB
testcase_11 AC 38 ms
39,680 KB
testcase_12 AC 43 ms
41,728 KB
testcase_13 AC 33 ms
35,584 KB
testcase_14 AC 33 ms
38,124 KB
testcase_15 AC 37 ms
41,680 KB
testcase_16 AC 35 ms
38,068 KB
testcase_17 AC 34 ms
38,148 KB
testcase_18 AC 41 ms
45,836 KB
testcase_19 AC 42 ms
46,200 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 41 ms
45,980 KB
testcase_23 AC 86 ms
73,284 KB
testcase_24 AC 75 ms
65,448 KB
testcase_25 AC 84 ms
73,144 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 5 ms
10,856 KB
testcase_28 AC 75 ms
65,344 KB
testcase_29 AC 77 ms
69,356 KB
testcase_30 AC 75 ms
65,108 KB
testcase_31 AC 71 ms
60,800 KB
testcase_32 AC 77 ms
66,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
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