結果

問題 No.800 四平方定理
ユーザー mine691mine691
提出日時 2019-03-17 22:42:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 728 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 169,488 KB
実行使用メモリ 128,244 KB
最終ジャッジ日時 2023-09-22 08:44:43
合計ジャッジ時間 4,567 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 4 ms
5,532 KB
testcase_02 AC 3 ms
4,604 KB
testcase_03 AC 4 ms
4,864 KB
testcase_04 AC 3 ms
4,552 KB
testcase_05 AC 3 ms
4,888 KB
testcase_06 AC 5 ms
6,020 KB
testcase_07 AC 3 ms
5,164 KB
testcase_08 AC 4 ms
6,036 KB
testcase_09 AC 4 ms
5,384 KB
testcase_10 AC 42 ms
65,264 KB
testcase_11 AC 47 ms
72,588 KB
testcase_12 AC 48 ms
71,392 KB
testcase_13 AC 42 ms
67,716 KB
testcase_14 AC 48 ms
72,588 KB
testcase_15 AC 45 ms
72,144 KB
testcase_16 AC 49 ms
73,428 KB
testcase_17 AC 45 ms
73,468 KB
testcase_18 AC 49 ms
73,252 KB
testcase_19 AC 47 ms
73,488 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 50 ms
73,544 KB
testcase_23 AC 120 ms
128,160 KB
testcase_24 AC 115 ms
127,808 KB
testcase_25 AC 89 ms
127,572 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 RE -
testcase_28 AC 113 ms
127,332 KB
testcase_29 AC 94 ms
127,944 KB
testcase_30 AC 111 ms
127,844 KB
testcase_31 AC 76 ms
119,008 KB
testcase_32 AC 99 ms
128,244 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;
map<int, int> X, Y;

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