結果

問題 No.358 も~っと!門松列
ユーザー mokraimokrai
提出日時 2017-11-13 15:27:37
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 16 ms / 1,000 ms
コード長 766 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 7,996 KB
最終ジャッジ日時 2023-08-16 11:59:41
合計ジャッジ時間 1,954 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,948 KB
testcase_01 AC 16 ms
7,840 KB
testcase_02 AC 16 ms
7,848 KB
testcase_03 AC 16 ms
7,840 KB
testcase_04 AC 16 ms
7,948 KB
testcase_05 AC 16 ms
7,948 KB
testcase_06 AC 16 ms
7,784 KB
testcase_07 AC 16 ms
7,844 KB
testcase_08 AC 16 ms
7,948 KB
testcase_09 AC 16 ms
7,988 KB
testcase_10 AC 16 ms
7,760 KB
testcase_11 AC 16 ms
7,996 KB
testcase_12 AC 16 ms
7,848 KB
testcase_13 AC 16 ms
7,948 KB
testcase_14 AC 16 ms
7,904 KB
testcase_15 AC 16 ms
7,844 KB
testcase_16 AC 16 ms
7,844 KB
testcase_17 AC 16 ms
7,892 KB
testcase_18 AC 16 ms
7,852 KB
testcase_19 AC 16 ms
7,948 KB
testcase_20 AC 16 ms
7,980 KB
testcase_21 AC 16 ms
7,888 KB
testcase_22 AC 16 ms
7,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    A, B, C = map(int, input().split())
    if A == C:
        print("0")
    # すでに成立している
    elif A > B and B < C:
        print("INF")
    # すでに成立している
    elif A < B and B > C:
        print("INF")
    else:
        print(count_kadomatsu(A, B, C))

def count_kadomatsu(a, b, c):
    max_val = max([a, b, c])
    count = 0
    for i in range(max_val):
        divider = i + 1
        if check_kadomatsu(a % divider, b % divider, c % divider):
            count += 1
    return count

def check_kadomatsu(a, b, c):
    if a == b or b == c or c == a:
        return False
    elif a > b and b < c:
        return True
    elif a < b and b > c:
        return True
    else: False


if __name__ == '__main__':
    main()
0