結果

問題 No.1680 Sum and Difference
ユーザー ygd.ygd.
提出日時 2021-09-22 23:00:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 448 bytes
コンパイル時間 785 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 71,624 KB
最終ジャッジ日時 2023-09-18 19:43:40
合計ジャッジ時間 3,572 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,076 KB
testcase_01 AC 71 ms
71,008 KB
testcase_02 AC 72 ms
71,108 KB
testcase_03 AC 74 ms
71,384 KB
testcase_04 WA -
testcase_05 AC 73 ms
71,364 KB
testcase_06 AC 72 ms
71,068 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 74 ms
71,300 KB
testcase_13 AC 72 ms
71,240 KB
testcase_14 AC 74 ms
71,232 KB
testcase_15 WA -
testcase_16 AC 74 ms
71,324 KB
testcase_17 AC 79 ms
71,128 KB
testcase_18 AC 74 ms
71,192 KB
testcase_19 AC 74 ms
71,200 KB
testcase_20 AC 73 ms
71,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline

def main():
    A,B = map(int,input().split()); MOD = pow(10,9) + 7
    if A <= B:
        A += 1
        ans = A*(A+1)*(2*A+1)//6
    else:
        if A%2 == 1:
            a = 1 + (B//2)*2
            a1 = 2*B + 1 - a
        else:
            a = 1 + (B//2)*2
            a1 = 2*B + 1 - a
            a,a1 = a1,a
        ans = A*a + (A+1)*a1
    print(ans%MOD)

if __name__ == '__main__':
    main()
0