結果

問題 No.800 四平方定理
ユーザー ty70ty70
提出日時 2019-03-18 00:33:42
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 763 bytes
コンパイル時間 2,322 ms
コンパイル使用メモリ 143,384 KB
実行使用メモリ 42,668 KB
最終ジャッジ日時 2023-09-22 16:16:29
合計ジャッジ時間 6,315 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
42,488 KB
testcase_01 AC 19 ms
42,436 KB
testcase_02 AC 18 ms
42,412 KB
testcase_03 AC 18 ms
42,436 KB
testcase_04 AC 18 ms
42,428 KB
testcase_05 AC 18 ms
42,504 KB
testcase_06 AC 18 ms
42,364 KB
testcase_07 AC 19 ms
42,544 KB
testcase_08 AC 19 ms
42,368 KB
testcase_09 AC 19 ms
42,428 KB
testcase_10 AC 35 ms
42,588 KB
testcase_11 AC 37 ms
42,468 KB
testcase_12 AC 38 ms
42,432 KB
testcase_13 AC 35 ms
42,668 KB
testcase_14 AC 36 ms
42,476 KB
testcase_15 AC 39 ms
42,456 KB
testcase_16 AC 37 ms
42,448 KB
testcase_17 AC 37 ms
42,460 KB
testcase_18 AC 41 ms
42,536 KB
testcase_19 AC 40 ms
42,468 KB
testcase_20 AC 19 ms
42,440 KB
testcase_21 AC 18 ms
42,436 KB
testcase_22 AC 41 ms
42,488 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 19 ms
42,364 KB
testcase_27 AC 19 ms
42,436 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;

const int MAX_N2 = (int)5e6 + 1;
int cnt1[MAX_N2];
int cnt2[MAX_N2];
	
int main()
{
	memset(cnt1, 0, sizeof(cnt1));
	memset(cnt2, 0, sizeof(cnt2));

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, D; cin >> N >> D;

	for (int x = 1; x <= N; ++x){
		for (int y = 1; y <= N; ++y){
			++cnt1[x*x + y*y];
		} // end for
	} // end for

	for (int w = 1; w <= N; ++w){
		for (int z = 1; z <= N; ++z){
			int i = w * w - z * z + D;
			if (i >= 0){
				++cnt2[i];
			} // end if
		} // end for
	} // end for

	ll res = 0LL;
	rep (i, MAX_N2){
		res += (ll)cnt1[i] * cnt2[i];
	} // end rep
	cout << res << endl;

	return 0;
}
0