結果

問題 No.2368 I love a square root of 2
ユーザー tassei903tassei903
提出日時 2023-07-01 19:36:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 919 ms / 2,000 ms
コード長 1,249 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 105,564 KB
最終ジャッジ日時 2023-09-22 13:48:57
合計ジャッジ時間 11,195 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 213 ms
104,272 KB
testcase_01 AC 213 ms
104,164 KB
testcase_02 AC 875 ms
104,496 KB
testcase_03 AC 223 ms
103,060 KB
testcase_04 AC 221 ms
103,344 KB
testcase_05 AC 225 ms
103,364 KB
testcase_06 AC 226 ms
103,312 KB
testcase_07 AC 218 ms
103,512 KB
testcase_08 AC 226 ms
103,116 KB
testcase_09 AC 222 ms
103,568 KB
testcase_10 AC 227 ms
103,380 KB
testcase_11 AC 225 ms
103,208 KB
testcase_12 AC 223 ms
103,516 KB
testcase_13 AC 718 ms
102,776 KB
testcase_14 AC 749 ms
102,764 KB
testcase_15 AC 805 ms
103,032 KB
testcase_16 AC 578 ms
102,336 KB
testcase_17 AC 238 ms
102,872 KB
testcase_18 AC 246 ms
103,724 KB
testcase_19 AC 249 ms
103,408 KB
testcase_20 AC 246 ms
103,532 KB
testcase_21 AC 919 ms
105,564 KB
testcase_22 AC 889 ms
103,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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])
0