結果

問題 No.1803 Remainder of Sum
ユーザー 👑 tamatotamato
提出日時 2022-01-07 21:53:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 599 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 87,828 KB
実行使用メモリ 78,340 KB
最終ジャッジ日時 2023-08-09 03:12:58
合計ジャッジ時間 2,719 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,468 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 <= 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()
0