結果
| 問題 |
No.1803 Remainder of Sum
|
| ユーザー |
tamato
|
| 提出日時 | 2022-01-07 21:54:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 660 bytes |
| コンパイル時間 | 191 ms |
| コンパイル使用メモリ | 82,612 KB |
| 実行使用メモリ | 76,652 KB |
| 最終ジャッジ日時 | 2024-11-14 08:44:10 |
| 合計ジャッジ時間 | 2,005 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 8 |
ソースコード
mod = 1000000007
eps = 10**-9
def main():
import sys
input = sys.stdin.readline
for _ in range(int(input())):
N, M = map(int, input().split())
if M == 1:
print(0)
continue
if M <= N:
print((M + 1) // 2)
elif M == 2 * N:
print(N - 1 + N * (N + 1) // 2 - 1)
else:
K = M - N - 1
if K == 0:
print((N - K + 1) // 2)
elif K == 1:
print((N - K + 1) // 2 + 3)
else:
print((N - K + 1) // 2 + K - 1 + K * (K + 1) // 2 - 1 + K + 2)
if __name__ == '__main__':
main()
tamato