結果

問題 No.1803 Remainder of Sum
コンテスト
ユーザー NatsubiSogan
提出日時 2021-12-17 09:30:42
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 319 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 159 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 81,280 KB
最終ジャッジ日時 2026-04-04 11:54:39
合計ジャッジ時間 1,824 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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