結果

問題 No.800 四平方定理
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-04-08 09:23:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 1,120 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 73,576 KB
実行使用メモリ 65,564 KB
最終ジャッジ日時 2023-09-14 15:37:34
合計ジャッジ時間 3,037 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,400 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,476 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,384 KB
testcase_09 AC 2 ms
4,448 KB
testcase_10 AC 37 ms
34,380 KB
testcase_11 AC 40 ms
37,864 KB
testcase_12 AC 42 ms
37,288 KB
testcase_13 AC 35 ms
35,472 KB
testcase_14 AC 38 ms
37,936 KB
testcase_15 AC 42 ms
37,480 KB
testcase_16 AC 39 ms
38,308 KB
testcase_17 AC 40 ms
38,272 KB
testcase_18 AC 46 ms
37,888 KB
testcase_19 AC 47 ms
38,452 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 46 ms
38,204 KB
testcase_23 AC 93 ms
65,564 KB
testcase_24 AC 86 ms
65,556 KB
testcase_25 AC 93 ms
65,432 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 83 ms
65,164 KB
testcase_29 AC 90 ms
65,372 KB
testcase_30 AC 84 ms
65,416 KB
testcase_31 AC 76 ms
61,048 KB
testcase_32 AC 87 ms
65,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int,int>

#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int main() {
    int N, D;
    cin >> N >> D;
    vector<int> XY(2 * N * N + 1, 0), ZW(2 * N * N + 1, 0);
    for (int x = 1; x <= N; x++)
    {
        for (int y = 1; y <= N; y++)
        {
            XY[x*x + y*y]++;
        }
    }
    for (int w = 1; w <= N; w++)
    {
        for (int z = 1; z <= N; z++)
        {
            int k = w * w - z * z + D;
            if (k >= 2 && k <= 2 * N * N) {
                ZW[k]++;
            }
            else if (k <= 1) {
                break;
            }
        }
    }
    ll cnt = 0;
    for (int i = 0; i <= 2 * N * N; i++)
    {
        cnt += XY[i] * ZW[i];
    }
    cout << cnt << endl;
    getchar(); getchar();
    return 0;
}
0