結果

問題 No.799 赤黒かーどげぇむ
ユーザー _KingdomOfMoray_KingdomOfMoray
提出日時 2019-12-20 17:51:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,066 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 11,020 KB
実行使用メモリ 8,836 KB
最終ジャッジ日時 2023-09-22 23:57:17
合計ジャッジ時間 1,462 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,756 KB
testcase_01 AC 21 ms
8,656 KB
testcase_02 AC 20 ms
8,704 KB
testcase_03 AC 21 ms
8,752 KB
testcase_04 AC 20 ms
8,748 KB
testcase_05 AC 21 ms
8,800 KB
testcase_06 AC 20 ms
8,796 KB
testcase_07 AC 20 ms
8,832 KB
testcase_08 AC 20 ms
8,792 KB
testcase_09 AC 20 ms
8,836 KB
testcase_10 AC 20 ms
8,688 KB
testcase_11 AC 20 ms
8,656 KB
testcase_12 AC 20 ms
8,752 KB
testcase_13 AC 20 ms
8,656 KB
testcase_14 AC 20 ms
8,816 KB
testcase_15 AC 20 ms
8,832 KB
testcase_16 AC 20 ms
8,704 KB
testcase_17 AC 20 ms
8,624 KB
testcase_18 AC 20 ms
8,760 KB
testcase_19 AC 20 ms
8,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def max(a,b):
    return a if a >= b else b

input_list = list(map(int,input().split()))
a = input_list[0]
b = input_list[1]
c = input_list[2]
d = input_list[3]

# a~b, c~d中の、重複を許した数字の個数
num_overlap = (b - a + 1) * (d - c + 1)

# # num_overlapから2個とる組み合わせの数
# comb_overlap = cmb(num_overlap, 2)

# print('comb_overlap: {}'.format(comb_overlap))

# 被っている範囲の組み合わせの数
range_overlap = 0
if d < a or b < c:
#     print('ダブり無し')
    range_overlap = 0
else:
    if d < b:
#         print('pass1')
        range_overlap = d - max(a, c) + 1
    else:
        if a < c:
#             print('pass2')
            range_overlap = b - c + 1
        else:
#             print('pass3')
            range_overlap = b - a + 1

res = num_overlap - range_overlap

print(res)
0