結果

問題 No.1680 Sum and Difference
ユーザー ygd.
提出日時 2021-09-22 23:26:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 1,000 ms
コード長 405 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 81,860 KB
実行使用メモリ 52,096 KB
最終ジャッジ日時 2024-07-05 09:21:23
合計ジャッジ時間 1,678 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline

def main():
    A,B = map(int,input().split()); MOD = pow(10,9) + 7
    if B%2 == 0:
        #スタートB+1
        x = ((A+1)//2)*2
        y = (A//2)*2 + 1
        ans = x*B + y*(B+1)
    else:
        #スタートがB
        x = ((A+1)//2)*2
        y = (A//2)*2 + 1
        ans = x*(B+1) + y*B
    print(ans%MOD)

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