結果

問題 No.1803 Remainder of Sum
コンテスト
ユーザー NatsubiSogan
提出日時 2021-12-17 09:30:42
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 100 ms / 2,000 ms
+ 549µs
コード長 319 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 244 ms
コンパイル使用メモリ 95,976 KB
実行使用メモリ 84,224 KB
最終ジャッジ日時 2026-08-27 01:06:21
合計ジャッジ時間 4,413 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def main():     
    import sys
    input = sys.stdin.buffer.readline
    for _ in range(int(input())):
        n, m = map(int, input().split())
        if m <= n: print(m // 2)
        else:
            x = m - n
            print(x * (x + 1) // 2 - 1 + (x - 1) + m // 2 - x)
if __name__ == '__main__':
    main()
    
0