結果

問題 No.1680 Sum and Difference
ユーザー aaaaaaaaaa2230
提出日時 2021-09-17 21:49:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 420 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2024-06-29 20:14:43
合計ジャッジ時間 1,641 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

a,b = map(int,input().split())
mod = 10**9+7
if a*b == 0:
    if a%2 or b%2:
        print((a+b)%mod)
    else:
        print((a+b+1)%mod)
    exit()
if a > b:
    a,b = b,a
if a%2 == b%2:
    l = (a-b)//2
    r = (b-a)//2
    ans = (r-l+1)*(2*a+1)%mod

    ans += (2*a-1+1)*((2*a+1)//2)%mod

else:
    l = (a-b+1)//2
    r = (b-a-1)//2
    ans = (r-l+1)*(2*a+1)%mod
    ans += (2*a-1+1)*((2*a+1)//2)%mod

print(ans%mod)
0