結果

問題 No.2368 I love a square root of 2
ユーザー navel_tosnavel_tos
提出日時 2024-02-17 16:52:04
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 774 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 281,268 KB
最終ジャッジ日時 2024-02-17 16:52:08
合計ジャッジ時間 4,555 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
60,264 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#yukicoder 2368 I love a square root of 2

from collections import deque

#入力受取
N = int(input())

#比較関数を定義  (x, y) = x + y√2 として、前者のほうが小さいか判定する
def compare(P1, P2):
    x1, y1 = P1
    x2, y2 = P2
    return (x1 - x2) ** 2 <= 2 * (y1 - y2) ** 2

#2つの筒を用意  Q[0]は長さ1, Q[1]は長さ√2
Q = [deque([(1, 0)]), deque([(0, 1)])]

#1個目の処理を終えた状態から始める
x = y = 0
for _ in range(N - 1):
    i = 0 if compare(Q[0][0], Q[1][0]) else 1
    #Q[i]の先頭要素を取り出す
    x,y = Q[i].popleft()

    #次の値に遷移  y == 0の時に限り長さ1の筒に入れる
    if y == 0:
        Q[0].append((x + 1, y))
    Q[1].append((x, y + 1))

#答えを出力
print(x,y)
0