結果

問題 No.800 四平方定理
ユーザー aa
提出日時 2019-03-17 22:04:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 468 bytes
コンパイル時間 1,391 ms
コンパイル使用メモリ 165,600 KB
実行使用メモリ 34,536 KB
最終ジャッジ日時 2023-09-22 06:25:30
合計ジャッジ時間 3,869 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 21 ms
18,324 KB
testcase_11 AC 25 ms
20,520 KB
testcase_12 AC 25 ms
19,960 KB
testcase_13 AC 21 ms
19,224 KB
testcase_14 AC 23 ms
20,416 KB
testcase_15 AC 27 ms
20,252 KB
testcase_16 AC 25 ms
20,584 KB
testcase_17 AC 24 ms
20,668 KB
testcase_18 AC 27 ms
20,456 KB
testcase_19 AC 26 ms
20,728 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 28 ms
20,636 KB
testcase_23 AC 69 ms
34,292 KB
testcase_24 AC 62 ms
34,312 KB
testcase_25 AC 64 ms
34,536 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 RE -
testcase_28 AC 61 ms
34,148 KB
testcase_29 AC 66 ms
34,224 KB
testcase_30 AC 65 ms
33,956 KB
testcase_31 AC 56 ms
31,996 KB
testcase_32 AC 61 ms
34,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int N, D, ans = 0;
	cin >> N >> D;
	vector<int> mp(N*N*2+1);
	for (int y = 1; y <= N; y++)
	{
		for (int z = 1; z <= N; z++)
		{
			mp[y*y+z*z]++;
		}
	}

	for (int x = 1; x <= N; x++)
	{
		for (int w = 1; w <= N; w++)
		{
			int p = D + w * w - x * x;
			if (p <= 0) continue;
			ans += mp[p];
		}
	}
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}
0