結果

問題 No.358 も~っと!門松列
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-04-18 22:06:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 31 ms / 1,000 ms
コード長 659 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-15 03:39:52
合計ジャッジ時間 1,523 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 27 ms
10,880 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 30 ms
10,880 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 30 ms
10,880 KB
testcase_07 AC 29 ms
10,880 KB
testcase_08 AC 30 ms
10,752 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 AC 28 ms
10,752 KB
testcase_11 AC 29 ms
10,752 KB
testcase_12 AC 28 ms
10,752 KB
testcase_13 AC 27 ms
11,008 KB
testcase_14 AC 31 ms
10,880 KB
testcase_15 AC 28 ms
10,880 KB
testcase_16 AC 29 ms
10,752 KB
testcase_17 AC 30 ms
10,752 KB
testcase_18 AC 28 ms
10,880 KB
testcase_19 AC 28 ms
10,752 KB
testcase_20 AC 31 ms
10,880 KB
testcase_21 AC 29 ms
10,752 KB
testcase_22 AC 31 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array


INF = -1


def is_kadomatsu_seq(seq):
    l = len(seq)
    cond0 = l == 3
    cond1 = len(set(seq)) == l
    cond2 = seq[1] == max(seq) or seq[1] == min(seq)
    return cond0 and cond1 and cond2


def count_p(seq, typecode="I"):
    if is_kadomatsu_seq(seq):
        return INF
    x = max(seq)
    gen_b = lambda p: array.array(typecode, map(lambda y: y % p, seq))
    return sum(1 for p in range(1, x + 1) if is_kadomatsu_seq(gen_b(p)))


def main():
    ans = count_p(array.array("I", map(int, input().split())))
    print("INF" if ans == INF else ans)


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