結果
| 問題 |
No.3048 Swing
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2025-03-07 21:08:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| コード長 | 555 bytes |
| コンパイル時間 | 314 ms |
| コンパイル使用メモリ | 81,780 KB |
| 実行使用メモリ | 53,996 KB |
| 最終ジャッジ日時 | 2025-06-20 02:23:16 |
| 合計ジャッジ時間 | 3,846 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 62 |
ソースコード
x, n = map(int, input().split())
i = 0
if x > 0:
# x-i(i+1)/2<=0
l, r = 0, 10 ** 10
while r - l > 1:
c = (l + r) // 2
if c * (c + 1) // 2 >= x:
r = c
else:
l = c
i = min(l, n)
x -= i * (i + 1) // 2
else:
# x+i(i+1)/2>0
l, r = 0, 10 ** 10
while r - l > 1:
c = (l + r) // 2
if x + c * (c + 1) // 2 > 0:
r = c
else:
l = c
i = min(r, n)
x += i * (i + 1) // 2
t = (n - i) // 2
x += t
i += 2 * t
if i < n:
x -= n
print(x)
Kude