結果
| 問題 |
No.1680 Sum and Difference
|
| コンテスト | |
| ユーザー |
asumo0729
|
| 提出日時 | 2021-09-17 22:12:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 929 bytes |
| コンパイル時間 | 159 ms |
| コンパイル使用メモリ | 82,180 KB |
| 実行使用メモリ | 55,432 KB |
| 最終ジャッジ日時 | 2024-06-29 20:47:35 |
| 合計ジャッジ時間 | 1,817 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 1 |
ソースコード
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)
asumo0729