結果

問題 No.800 四平方定理
ユーザー mine691mine691
提出日時 2019-03-17 23:06:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 1,420 ms
コンパイル使用メモリ 167,404 KB
実行使用メモリ 104,652 KB
最終ジャッジ日時 2023-09-22 09:48:19
合計ジャッジ時間 3,970 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,964 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,440 KB
testcase_04 AC 2 ms
4,496 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
5,228 KB
testcase_07 AC 2 ms
5,368 KB
testcase_08 AC 4 ms
7,196 KB
testcase_09 AC 3 ms
4,900 KB
testcase_10 AC 38 ms
53,104 KB
testcase_11 AC 44 ms
57,044 KB
testcase_12 AC 44 ms
58,572 KB
testcase_13 AC 37 ms
51,776 KB
testcase_14 AC 39 ms
55,196 KB
testcase_15 AC 43 ms
58,776 KB
testcase_16 AC 39 ms
55,784 KB
testcase_17 AC 40 ms
56,048 KB
testcase_18 AC 47 ms
63,512 KB
testcase_19 AC 47 ms
63,512 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 47 ms
63,440 KB
testcase_23 AC 95 ms
104,652 KB
testcase_24 AC 84 ms
96,876 KB
testcase_25 AC 92 ms
104,396 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 5 ms
11,080 KB
testcase_28 AC 84 ms
96,724 KB
testcase_29 AC 90 ms
100,572 KB
testcase_30 AC 83 ms
96,412 KB
testcase_31 AC 77 ms
90,088 KB
testcase_32 AC 86 ms
97,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll n, d, ans;
int main()
{
    cin >> n >> d;
    vector<ll> X(3 * 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