結果
| 問題 |
No.1286 Stone Skipping
|
| コンテスト | |
| ユーザー |
semisagi
|
| 提出日時 | 2020-11-13 21:38:22 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 571 bytes |
| コンパイル時間 | 88 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2024-07-23 09:50:23 |
| 合計ジャッジ時間 | 2,450 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 1 |
ソースコード
from fractions import Fraction
def read_int():
return int(input())
def read_ints():
return list(map(int, input().split()))
D = read_int()
def f(x):
y = 0
while x != 0:
y += x
if y == D:
return True
x //= 2
return False
answer = 10 ** 100
for i in range(1, 100):
# x(1 + 1/2 + 1/4 + 1/8 + ...) ~= D
x = Fraction(D) / ((1 - Fraction(1, 2) ** i) / (1 - Fraction(1, 2)))
x = int(x)
for d in range(-10, 10):
if x + d >= 1 and f(x + d):
answer = min(answer, x + d)
print(answer)
semisagi