結果

問題 No.1680 Sum and Difference
ユーザー tktk_snsntktk_snsn
提出日時 2021-09-17 21:42:25
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 15 ms / 1,000 ms
コード長 408 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 10,568 KB
実行使用メモリ 8,120 KB
最終ジャッジ日時 2023-09-12 07:08:11
合計ジャッジ時間 1,559 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,860 KB
testcase_01 AC 14 ms
8,104 KB
testcase_02 AC 14 ms
7,920 KB
testcase_03 AC 15 ms
7,940 KB
testcase_04 AC 14 ms
7,936 KB
testcase_05 AC 14 ms
8,116 KB
testcase_06 AC 14 ms
8,120 KB
testcase_07 AC 15 ms
7,844 KB
testcase_08 AC 14 ms
7,864 KB
testcase_09 AC 15 ms
7,868 KB
testcase_10 AC 15 ms
7,884 KB
testcase_11 AC 15 ms
7,820 KB
testcase_12 AC 15 ms
7,952 KB
testcase_13 AC 15 ms
7,984 KB
testcase_14 AC 15 ms
7,792 KB
testcase_15 AC 15 ms
7,852 KB
testcase_16 AC 15 ms
7,880 KB
testcase_17 AC 15 ms
7,792 KB
testcase_18 AC 15 ms
7,844 KB
testcase_19 AC 15 ms
7,856 KB
testcase_20 AC 15 ms
7,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0