結果
問題 | No.1680 Sum and Difference |
ユーザー |
![]() |
提出日時 | 2021-09-17 21:42:25 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 26 ms / 1,000 ms |
コード長 | 408 bytes |
コンパイル時間 | 175 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-06-29 20:06:57 |
合計ジャッジ時間 | 1,342 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
mod = 10 ** 9 + 7 A, B = map(int, input().split()) if A > B: A, B = B, A if A == 0 and B == 0: print(1) exit() if A == 0: if B % 2 == 0: print((B + 1) % mod) else: print(B % mod) exit() if (A + B) % 2 == 0: b = 2 * (A + 1 + B + 1) - 4 S = 2 * A * B ans = S + 1 + b // 2 print(ans % mod) else: ans = A * (B + 1) + B * (A + 1) print(ans % mod)