結果

問題 No.1680 Sum and Difference
ユーザー asumo0729asumo0729
提出日時 2021-09-17 22:12:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 929 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 87,364 KB
実行使用メモリ 72,012 KB
最終ジャッジ日時 2023-09-12 07:54:20
合計ジャッジ時間 3,222 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,252 KB
testcase_01 AC 93 ms
71,612 KB
testcase_02 AC 92 ms
71,520 KB
testcase_03 AC 96 ms
71,592 KB
testcase_04 AC 92 ms
71,568 KB
testcase_05 WA -
testcase_06 AC 93 ms
71,536 KB
testcase_07 AC 93 ms
71,516 KB
testcase_08 AC 92 ms
72,012 KB
testcase_09 AC 92 ms
71,668 KB
testcase_10 AC 92 ms
71,624 KB
testcase_11 AC 93 ms
71,516 KB
testcase_12 AC 92 ms
71,472 KB
testcase_13 AC 93 ms
71,680 KB
testcase_14 AC 93 ms
71,588 KB
testcase_15 AC 91 ms
71,256 KB
testcase_16 AC 92 ms
71,572 KB
testcase_17 AC 92 ms
71,540 KB
testcase_18 AC 90 ms
71,612 KB
testcase_19 AC 90 ms
71,520 KB
testcase_20 AC 90 ms
71,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter
from collections import defaultdict, deque
import heapq
import bisect

stdin=sys.stdin
sys.setrecursionlimit(10 ** 8)

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
Yp=lambda:print('Yes')
Np=lambda:print('No')
inf = 1 << 60
eps = 1e-9
sortkey = itemgetter(0)
mod = 10 ** 9 + 7

###############################################################

A, B = lp()
A, B = max(A, B), min(A, B)
if B == 0:
    ans = A
else:
    ans = 0
    if (A + B) % 2 == 0:
        x = B * 2 + 1
        wide = (A - B) // 2
        ans += (2 * wide + 1) * x 
        p = (x - 1) // 2 + 1
        ans += (x + 1) * p 
        ans -= 2 * x
    else:
        x = B * 2 + 1
        wide = (A - B) // 2
        ans += (wide * 2 + 1) * x
        x -= 1
        p = (x - 2) // 2 + 1
        ans += (x + 2) * p
    ans %= mod
print(ans)
0