結果

問題 No.800 四平方定理
ユーザー BwambocosBwambocos
提出日時 2019-03-17 23:15:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 621 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 164,084 KB
実行使用メモリ 8,764 KB
最終ジャッジ日時 2023-09-22 10:21:08
合計ジャッジ時間 5,443 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,764 KB
testcase_01 AC 41 ms
4,384 KB
testcase_02 AC 24 ms
4,380 KB
testcase_03 AC 28 ms
4,380 KB
testcase_04 AC 25 ms
4,384 KB
testcase_05 AC 30 ms
4,380 KB
testcase_06 AC 49 ms
4,384 KB
testcase_07 AC 29 ms
4,384 KB
testcase_08 AC 33 ms
4,384 KB
testcase_09 AC 41 ms
4,380 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
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"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, D;
	in >> N >> D;

	LL ans = 0, max = N * N + D;
	LL maxx = std::min<LL>(N, sqrt(max));
	for (LL x = 1; x <= maxx; ++x)
	{
		if (x * x > max) continue;
		for (LL y = 1; y <= maxx; ++y)
		{
			if (x * x + y * y > max) continue;
			for (LL z = 1; z <= maxx; ++z)
			{
				if (x * x + y * y + z * z > max) continue;
				LL w2 = x * x + y * y + z * z - D;
				if (w2 > 0)
				{
					LL w = sqrt(w2);
					if (w*w == w2) ++ans;
				}
			}
		}
	}

	out << ans << std::endl;
}
0