結果

問題 No.800 四平方定理
ユーザー potoooooooopotoooooooo
提出日時 2019-03-21 20:39:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 1,531 ms
コンパイル使用メモリ 166,844 KB
実行使用メモリ 104,928 KB
最終ジャッジ日時 2023-10-19 05:41:05
合計ジャッジ時間 4,571 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,952 KB
testcase_01 AC 3 ms
6,248 KB
testcase_02 AC 3 ms
6,060 KB
testcase_03 AC 3 ms
6,112 KB
testcase_04 AC 3 ms
6,088 KB
testcase_05 AC 3 ms
6,152 KB
testcase_06 AC 4 ms
8,356 KB
testcase_07 AC 3 ms
8,108 KB
testcase_08 AC 4 ms
9,736 KB
testcase_09 AC 3 ms
6,248 KB
testcase_10 AC 62 ms
57,508 KB
testcase_11 AC 64 ms
61,604 KB
testcase_12 AC 67 ms
61,604 KB
testcase_13 AC 55 ms
55,460 KB
testcase_14 AC 60 ms
59,556 KB
testcase_15 AC 69 ms
63,652 KB
testcase_16 AC 61 ms
59,556 KB
testcase_17 AC 61 ms
59,556 KB
testcase_18 AC 76 ms
67,748 KB
testcase_19 AC 76 ms
67,748 KB
testcase_20 AC 2 ms
5,640 KB
testcase_21 AC 2 ms
5,640 KB
testcase_22 AC 77 ms
67,748 KB
testcase_23 AC 133 ms
104,928 KB
testcase_24 AC 118 ms
96,736 KB
testcase_25 AC 134 ms
104,872 KB
testcase_26 AC 2 ms
5,640 KB
testcase_27 AC 3 ms
7,688 KB
testcase_28 AC 118 ms
96,632 KB
testcase_29 AC 127 ms
100,788 KB
testcase_30 AC 117 ms
96,648 KB
testcase_31 AC 107 ms
92,324 KB
testcase_32 AC 118 ms
98,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long v[8000010], w[8000010];

int main() {
    long long n, d; cin >> n >> d;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            v[i*i+j*j]++;
            if (i*i-j*j+d >= 0) w[i*i-j*j+d]++;
        }
    }
    long long ans = 0;
    for (int i = 0; i <= n*n*2; i++) {
        ans += v[i] * w[i];
    }
    cout << ans << endl;
    return 0;
}
0