結果

問題 No.1680 Sum and Difference
ユーザー ygd.ygd.
提出日時 2021-09-22 23:04:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 428 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 71,516 KB
最終ジャッジ日時 2023-09-18 19:43:47
合計ジャッジ時間 2,865 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,248 KB
testcase_01 AC 79 ms
71,120 KB
testcase_02 AC 75 ms
71,132 KB
testcase_03 AC 75 ms
71,284 KB
testcase_04 WA -
testcase_05 AC 75 ms
71,384 KB
testcase_06 AC 76 ms
71,224 KB
testcase_07 AC 75 ms
71,448 KB
testcase_08 WA -
testcase_09 AC 75 ms
71,180 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 76 ms
71,372 KB
testcase_13 AC 77 ms
71,436 KB
testcase_14 AC 76 ms
71,292 KB
testcase_15 WA -
testcase_16 AC 75 ms
71,348 KB
testcase_17 AC 75 ms
71,232 KB
testcase_18 AC 76 ms
71,336 KB
testcase_19 AC 76 ms
71,236 KB
testcase_20 AC 77 ms
71,516 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:
        ans = 1 + 2*(A+1)*A
    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