結果

問題 No.2368 I love a square root of 2
ユーザー shobonvipshobonvip
提出日時 2023-06-30 05:20:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 87,676 KB
実行使用メモリ 86,888 KB
最終ジャッジ日時 2023-09-20 23:55:18
合計ジャッジ時間 5,169 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
77,416 KB
testcase_01 AC 100 ms
77,372 KB
testcase_02 AC 251 ms
86,652 KB
testcase_03 AC 105 ms
77,436 KB
testcase_04 AC 106 ms
77,416 KB
testcase_05 AC 106 ms
77,188 KB
testcase_06 AC 106 ms
77,488 KB
testcase_07 AC 105 ms
77,364 KB
testcase_08 AC 106 ms
77,404 KB
testcase_09 AC 107 ms
77,324 KB
testcase_10 AC 108 ms
77,328 KB
testcase_11 AC 106 ms
77,600 KB
testcase_12 AC 108 ms
77,508 KB
testcase_13 AC 220 ms
84,680 KB
testcase_14 AC 219 ms
84,620 KB
testcase_15 AC 227 ms
85,736 KB
testcase_16 AC 186 ms
82,424 KB
testcase_17 AC 117 ms
78,160 KB
testcase_18 AC 116 ms
78,012 KB
testcase_19 AC 116 ms
77,868 KB
testcase_20 AC 115 ms
77,928 KB
testcase_21 AC 245 ms
86,888 KB
testcase_22 AC 257 ms
86,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random

sqrt2 = 2 ** 0.5

def cntunderk(k):
	y = 0
	cnt = 0
	for x in range(k, -1, -1):
		while True:
			y += 1
			if x + sqrt2 * y >= k:
				y -= 1
				break
		cnt += y + 1
	return cnt

n = int(input()) + 1
mx = 300000

ub = mx
lb = -1
while ub - lb > 1:
	k = (ub + lb) // 2
	if cntunderk(k) < n:
		lb = k
	else:
		ub = k

y = 0
s = []

for x in range(lb, -1, -1):
	while True:
		if x + sqrt2 * y < lb:
			y += 1
			continue
		break
	if x + sqrt2 * y < lb + 1:
		s.append((x, y))

s.sort(key = lambda x : x[0] + x[1] * sqrt2)
n -= cntunderk(lb)
#print(s)
print(*s[n-1])
0