結果

問題 No.800 四平方定理
ユーザー sprng_wlsprng_wl
提出日時 2019-03-18 22:25:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 1,811 ms
コンパイル使用メモリ 143,492 KB
実行使用メモリ 55,036 KB
最終ジャッジ日時 2023-09-26 12:19:10
合計ジャッジ時間 4,550 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,592 KB
testcase_01 AC 9 ms
5,684 KB
testcase_02 AC 9 ms
5,596 KB
testcase_03 AC 9 ms
5,696 KB
testcase_04 AC 10 ms
5,604 KB
testcase_05 AC 9 ms
5,944 KB
testcase_06 AC 9 ms
5,812 KB
testcase_07 AC 9 ms
5,912 KB
testcase_08 AC 10 ms
6,112 KB
testcase_09 AC 9 ms
5,776 KB
testcase_10 AC 33 ms
30,104 KB
testcase_11 AC 36 ms
32,004 KB
testcase_12 AC 36 ms
34,124 KB
testcase_13 AC 31 ms
30,160 KB
testcase_14 AC 36 ms
32,016 KB
testcase_15 AC 38 ms
34,132 KB
testcase_16 AC 33 ms
32,068 KB
testcase_17 AC 36 ms
32,212 KB
testcase_18 AC 40 ms
36,100 KB
testcase_19 AC 38 ms
36,164 KB
testcase_20 AC 9 ms
5,384 KB
testcase_21 AC 9 ms
5,460 KB
testcase_22 AC 40 ms
36,112 KB
testcase_23 AC 85 ms
55,036 KB
testcase_24 AC 79 ms
51,220 KB
testcase_25 AC 89 ms
55,024 KB
testcase_26 AC 9 ms
5,400 KB
testcase_27 AC 10 ms
7,568 KB
testcase_28 AC 88 ms
50,928 KB
testcase_29 AC 90 ms
53,004 KB
testcase_30 AC 81 ms
50,836 KB
testcase_31 AC 72 ms
50,500 KB
testcase_32 AC 79 ms
50,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int sz = 2 * 2000 * 2000;
int a[sz + 1] = { 0 };
int b[sz + 1] = { 0 };

int main() {
	int N, D;
	cin >> N >> D;

	for (int x = 1; x <= N; ++x) {
		for (int y = 1; y <= N; ++y) {
			++a[x*x + y*y];
		}
	}
	for (int z = 1; z <= N; ++z) {
		for (int w = 1; w <= N; ++w) {
			int t = w*w + D - z*z;
			if ((t > 0) && (t <= sz)) { ++b[t]; }
		}
	}

	int res = 0;
	for (int i = 0; i <= sz; ++i) { res += (a[i] * b[i]); }
	cout << res << endl;

	return 0;
}
0