結果

問題 No.1593 Perfect Distance
ユーザー nautnaut
提出日時 2024-01-30 14:15:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 297 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 61,596 KB
最終ジャッジ日時 2024-01-30 14:15:21
合計ジャッジ時間 4,567 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 33 ms
53,460 KB
testcase_02 AC 33 ms
53,460 KB
testcase_03 AC 74 ms
53,460 KB
testcase_04 AC 33 ms
53,460 KB
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 37 ms
59,380 KB
testcase_07 AC 42 ms
59,380 KB
testcase_08 AC 58 ms
61,596 KB
testcase_09 AC 55 ms
61,596 KB
testcase_10 AC 52 ms
61,596 KB
testcase_11 AC 56 ms
61,596 KB
testcase_12 AC 62 ms
61,592 KB
testcase_13 AC 63 ms
61,596 KB
testcase_14 AC 64 ms
61,596 KB
testcase_15 AC 77 ms
61,596 KB
testcase_16 AC 85 ms
61,592 KB
testcase_17 AC 34 ms
53,460 KB
testcase_18 AC 38 ms
53,460 KB
testcase_19 AC 33 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

ans = 0

for x in range(1, N):
	if x * x > N * N:
		break
	
	y_min = 0
	y_max = 1 << 30
	
	while y_max - y_min > 1:
		mid = (y_min + y_max) // 2
		
		if x * x + mid * mid >= N * N:
			y_max = mid
		else:
			y_min = mid
	
	if x * x + y_max * y_max == N * N:
		ans += 1

print(ans)
0