結果

問題 No.800 四平方定理
ユーザー mine691mine691
提出日時 2019-03-17 22:49:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 388 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 1,803 ms
コンパイル使用メモリ 166,776 KB
実行使用メモリ 323,232 KB
最終ジャッジ日時 2023-09-22 09:01:43
合計ジャッジ時間 7,130 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,224 KB
testcase_01 AC 7 ms
8,720 KB
testcase_02 AC 5 ms
7,292 KB
testcase_03 AC 6 ms
7,664 KB
testcase_04 AC 5 ms
6,952 KB
testcase_05 AC 5 ms
7,408 KB
testcase_06 AC 8 ms
10,208 KB
testcase_07 AC 6 ms
9,036 KB
testcase_08 AC 8 ms
12,096 KB
testcase_09 AC 7 ms
9,080 KB
testcase_10 AC 169 ms
161,360 KB
testcase_11 AC 185 ms
178,772 KB
testcase_12 AC 198 ms
178,300 KB
testcase_13 AC 103 ms
164,948 KB
testcase_14 AC 109 ms
176,872 KB
testcase_15 AC 115 ms
179,976 KB
testcase_16 AC 115 ms
178,800 KB
testcase_17 AC 112 ms
178,788 KB
testcase_18 AC 119 ms
185,804 KB
testcase_19 AC 138 ms
186,024 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 114 ms
186,796 KB
testcase_23 AC 388 ms
323,232 KB
testcase_24 AC 299 ms
315,512 KB
testcase_25 AC 303 ms
322,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 5 ms
10,784 KB
testcase_28 AC 296 ms
313,968 KB
testcase_29 AC 298 ms
318,872 KB
testcase_30 AC 288 ms
314,416 KB
testcase_31 AC 257 ms
292,340 KB
testcase_32 AC 288 ms
316,480 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(4 * n * n), Y(d + 6 * 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 + 3 * n * n]++;
        }
    }
    for (ll i = 1; i <= 2 * n * n; i++)
    {
        ans += X[i] * Y[d - i + 3 * n * n];
        //printf("X:%d Y:%d i:%d\n", X[i], Y[d - i], i);
    }
    cout << ans << endl;
}
0