結果

問題 No.800 四平方定理
ユーザー aa
提出日時 2019-03-17 22:06:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 1,597 ms
コンパイル使用メモリ 165,680 KB
実行使用メモリ 34,380 KB
最終ジャッジ日時 2023-09-22 06:32:34
合計ジャッジ時間 3,976 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 24 ms
18,360 KB
testcase_11 AC 29 ms
20,344 KB
testcase_12 AC 31 ms
19,988 KB
testcase_13 AC 26 ms
19,328 KB
testcase_14 AC 30 ms
20,472 KB
testcase_15 AC 34 ms
20,248 KB
testcase_16 AC 28 ms
20,656 KB
testcase_17 AC 30 ms
20,728 KB
testcase_18 AC 31 ms
20,648 KB
testcase_19 AC 33 ms
20,472 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 32 ms
20,668 KB
testcase_23 AC 78 ms
34,200 KB
testcase_24 AC 75 ms
34,380 KB
testcase_25 AC 77 ms
34,252 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 70 ms
34,036 KB
testcase_29 AC 75 ms
34,304 KB
testcase_30 AC 71 ms
34,032 KB
testcase_31 AC 64 ms
31,988 KB
testcase_32 AC 74 ms
34,164 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++)
		{
			int s = y*y+z*z;
			if (s<=N*N*2) mp[s]++;
		}
	}

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

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