結果

問題 No.800 四平方定理
ユーザー BwambocosBwambocos
提出日時 2019-03-17 23:15:57
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 740 bytes
コンパイル時間 1,305 ms
使用メモリ 6,952 KB
最終ジャッジ日時 2023-02-11 12:20:59
合計ジャッジ時間 28,761 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 4 ms
3,520 KB
testcase_01 AC 8 ms
3,372 KB
testcase_02 AC 5 ms
3,364 KB
testcase_03 AC 6 ms
3,436 KB
testcase_04 AC 5 ms
3,500 KB
testcase_05 AC 6 ms
3,372 KB
testcase_06 AC 9 ms
3,552 KB
testcase_07 AC 5 ms
3,528 KB
testcase_08 AC 6 ms
3,440 KB
testcase_09 AC 7 ms
3,364 KB
testcase_10 AC 794 ms
3,424 KB
testcase_11 AC 884 ms
3,524 KB
testcase_12 AC 919 ms
3,488 KB
testcase_13 AC 737 ms
3,516 KB
testcase_14 AC 816 ms
3,520 KB
testcase_15 AC 931 ms
3,520 KB
testcase_16 AC 829 ms
3,552 KB
testcase_17 AC 831 ms
3,472 KB
testcase_18 AC 988 ms
3,524 KB
testcase_19 AC 989 ms
3,372 KB
testcase_20 AC 1 ms
3,372 KB
testcase_21 AC 1 ms
3,536 KB
testcase_22 AC 998 ms
3,528 KB
testcase_23 TLE -
testcase_24 AC 1,952 ms
3,372 KB
testcase_25 TLE -
testcase_26 AC 1 ms
3,516 KB
testcase_27 AC 2 ms
3,492 KB
testcase_28 AC 1,937 ms
3,516 KB
testcase_29 TLE -
testcase_30 AC 1,945 ms
3,368 KB
testcase_31 AC 1,739 ms
3,516 KB
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

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 = x; y <= maxx; ++y)
		{
			if (x * x + y * y > max) continue;
			for (LL z = y; 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)
					{
						if (x == y && y == z) ans += 1;
						else if (x == y || x == z || y == z) ans += 3;
						else ans += 6;
					}
				}
			}
		}
	}

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