結果

問題 No.800 四平方定理
ユーザー aa
提出日時 2019-03-17 22:01:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 461 bytes
コンパイル時間 1,758 ms
コンパイル使用メモリ 172,524 KB
実行使用メモリ 73,964 KB
最終ジャッジ日時 2023-09-22 06:05:33
合計ジャッジ時間 5,984 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
8,800 KB
testcase_01 AC 25 ms
5,452 KB
testcase_02 AC 16 ms
4,948 KB
testcase_03 AC 20 ms
4,980 KB
testcase_04 AC 17 ms
4,804 KB
testcase_05 AC 20 ms
5,060 KB
testcase_06 AC 30 ms
5,732 KB
testcase_07 AC 29 ms
5,964 KB
testcase_08 AC 37 ms
7,072 KB
testcase_09 AC 24 ms
5,352 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int N, D, ans = 0;
	cin >> N >> D;
	map<int, int> mp;
	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