結果
| 問題 |
No.3048 Swing
|
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2025-03-07 21:12:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 758 bytes |
| コンパイル時間 | 534 ms |
| コンパイル使用メモリ | 82,052 KB |
| 実行使用メモリ | 54,124 KB |
| 最終ジャッジ日時 | 2025-03-07 21:12:43 |
| 合計ジャッジ時間 | 4,473 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 56 WA * 2 |
ソースコード
x,n=map(int,input().split())
if x>0:
ok=0
ng=10**10
while ng-ok>1:
m=(ok+ng)//2
if x-m*(m+1)//2>0:
ok=m
else:
ng=m
if ok>=n:
print(x-n*(n+1)//2)
exit()
x-=ok*(ok+1)//2
if (n-ok)%2:
print(x+(n-ok)//2-n)
else:
print(x+(n-ok)//2)
exit()
if x==0:
if n%2:
print(-n//2+n)
else:
print(-n//2)
exit()
if x<0:
ok=0
ng=10**10
while ng-ok>1:
m=(ok+ng)//2
if x+m*(m+1)//2<0:
ok=m
else:
ng=m
if ok>=n:
print(x+n*(n+1)//2)
exit()
x+=ok*(ok+1)//2
if ok+1<=n and x+(ok+1)==0:
x+=ok+1
if (n-ok-1)%2:
print(-(n-ok-1)//2+n)
else:
print(-(n-ok-1)//2)
exit()
if (n-ok)%2:
print(x-(n-ok)//2+n)
else:
print(x-(n-ok)//2)
exit()
sasa8uyauya