結果

問題 No.1286 Stone Skipping
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-16 20:03:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 379 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 77,060 KB
最終ジャッジ日時 2023-10-11 11:07:04
合計ジャッジ時間 5,126 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,524 KB
testcase_01 AC 74 ms
71,328 KB
testcase_02 AC 82 ms
76,632 KB
testcase_03 AC 77 ms
75,756 KB
testcase_04 AC 79 ms
75,580 KB
testcase_05 AC 78 ms
75,648 KB
testcase_06 AC 79 ms
75,768 KB
testcase_07 AC 78 ms
75,876 KB
testcase_08 AC 82 ms
76,628 KB
testcase_09 AC 88 ms
77,060 KB
testcase_10 AC 80 ms
76,640 KB
testcase_11 AC 80 ms
76,788 KB
testcase_12 AC 79 ms
76,616 KB
testcase_13 AC 82 ms
76,628 KB
testcase_14 AC 82 ms
76,960 KB
testcase_15 AC 81 ms
76,792 KB
testcase_16 AC 82 ms
76,656 KB
testcase_17 AC 83 ms
76,664 KB
testcase_18 AC 73 ms
71,376 KB
testcase_19 AC 73 ms
71,172 KB
testcase_20 AC 81 ms
76,452 KB
testcase_21 AC 81 ms
76,448 KB
testcase_22 AC 81 ms
76,680 KB
testcase_23 AC 82 ms
76,812 KB
testcase_24 AC 82 ms
76,680 KB
testcase_25 AC 80 ms
76,600 KB
testcase_26 AC 81 ms
76,664 KB
testcase_27 AC 80 ms
77,008 KB
testcase_28 AC 80 ms
76,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

d=int(input())
ans=d
for i in range(1,61):
  def func(x):
    tmp=0
    for _ in range(i):
      tmp+=x
      x//=2
      if x==0:break
    return tmp
  l,r=d//2,d
  while r-l>1:
    x=(l+r)//2
    t=func(x)
    if t==d:
      ans=min(ans,x)
      break
    elif d<t:
      l,r=l,x
    else:
      l,r=x,r
  if func(l)==d:ans=min(ans,l)
  if func(r)==d:ans=min(ans,r)
print(ans)
0