結果
| 問題 |
No.2368 I love a square root of 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-01 19:36:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 728 ms / 2,000 ms |
| コード長 | 1,249 bytes |
| コンパイル時間 | 238 ms |
| コンパイル使用メモリ | 81,992 KB |
| 実行使用メモリ | 103,036 KB |
| 最終ジャッジ日時 | 2024-07-08 05:28:19 |
| 合計ジャッジ時間 | 8,119 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
def f(b):
ok = 0
ng = 10**10
while abs(ok-ng)>1:
d = ok+ng>>1
if d*d <= 2*b*b:
ok = d
else:
ng = d
return ok
def comp(p, q):
if p[0] < q[0]:
return -comp(q, p)
if p[0] == q[0] and p[1] == q[1]:
return 0
if p[1] > q[1]:return 1
if (p[0]-q[0])**2 < 2 * (p[1]-q[1])**2:
return -1
return 1
n = ni()
c = []
m = 2*10**5
for i in range(m):
c.append(f(i))
d = []
s = 0
i = 0
j = 0
while i < m:
while i < m and c[i] <= j:
s += c[i]
i += 1
#print(j, i, s)
d.append(j * i - s)
j += 1
for i in range(len(d)):
if d[i] >= n:
ans = i
break
#print(ans)
p = []
b = 0
while True:
a = ans - f(b) - 1
if a < 0:
break
p.append((a, b))
b += 1
from functools import cmp_to_key
print(*sorted(p, key=cmp_to_key(comp))[n-d[ans]-1])