結果

問題 No.800 四平方定理
ユーザー mine691mine691
提出日時 2019-03-17 22:53:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 1,382 ms
コンパイル使用メモリ 166,668 KB
実行使用メモリ 229,896 KB
最終ジャッジ日時 2023-09-22 09:11:21
合計ジャッジ時間 5,095 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,164 KB
testcase_01 AC 5 ms
6,996 KB
testcase_02 AC 4 ms
5,944 KB
testcase_03 AC 4 ms
6,284 KB
testcase_04 AC 4 ms
5,644 KB
testcase_05 AC 5 ms
6,192 KB
testcase_06 AC 5 ms
8,056 KB
testcase_07 AC 5 ms
7,596 KB
testcase_08 AC 5 ms
9,980 KB
testcase_09 AC 5 ms
7,216 KB
testcase_10 AC 74 ms
115,204 KB
testcase_11 AC 86 ms
126,736 KB
testcase_12 AC 87 ms
127,092 KB
testcase_13 AC 75 ms
116,340 KB
testcase_14 AC 83 ms
124,780 KB
testcase_15 AC 82 ms
128,248 KB
testcase_16 AC 89 ms
126,348 KB
testcase_17 AC 85 ms
126,112 KB
testcase_18 AC 89 ms
133,412 KB
testcase_19 AC 88 ms
133,436 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 88 ms
133,964 KB
testcase_23 AC 229 ms
229,896 KB
testcase_24 AC 188 ms
221,800 KB
testcase_25 AC 207 ms
229,156 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 4 ms
10,768 KB
testcase_28 AC 191 ms
220,736 KB
testcase_29 AC 205 ms
225,200 KB
testcase_30 AC 173 ms
220,968 KB
testcase_31 AC 161 ms
205,712 KB
testcase_32 AC 184 ms
222,676 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), Y(d + 4 * n * n);
    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++)
        {
            Y[i * i - j * j + 2 * n * n]++;
        }
    }
    for (ll i = 1; i <= 2 * n * n; i++)
    {
        ans += X[i] * Y[d - i + 2 * n * n];
        //printf("X:%d Y:%d i:%d\n", X[i], Y[d - i], i);
    }
    cout << ans << endl;
}
0