結果

問題 No.312 置換処理
ユーザー しらっ亭しらっ亭
提出日時 2015-12-09 17:32:13
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 828 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 8,920 KB
最終ジャッジ日時 2023-08-09 15:47:51
合計ジャッジ時間 3,044 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
8,860 KB
testcase_01 AC 74 ms
8,908 KB
testcase_02 AC 130 ms
8,668 KB
testcase_03 AC 104 ms
8,724 KB
testcase_04 AC 21 ms
8,868 KB
testcase_05 AC 23 ms
8,728 KB
testcase_06 AC 27 ms
8,664 KB
testcase_07 AC 54 ms
8,832 KB
testcase_08 AC 25 ms
8,692 KB
testcase_09 AC 27 ms
8,868 KB
testcase_10 AC 21 ms
8,844 KB
testcase_11 AC 29 ms
8,868 KB
testcase_12 AC 20 ms
8,856 KB
testcase_13 AC 21 ms
8,748 KB
testcase_14 AC 21 ms
8,728 KB
testcase_15 AC 24 ms
8,696 KB
testcase_16 AC 21 ms
8,696 KB
testcase_17 AC 29 ms
8,872 KB
testcase_18 AC 20 ms
8,732 KB
testcase_19 AC 21 ms
8,864 KB
testcase_20 AC 25 ms
8,908 KB
testcase_21 AC 20 ms
8,872 KB
testcase_22 AC 20 ms
8,744 KB
testcase_23 AC 19 ms
8,740 KB
testcase_24 AC 19 ms
8,740 KB
testcase_25 AC 18 ms
8,856 KB
testcase_26 AC 19 ms
8,852 KB
testcase_27 AC 18 ms
8,740 KB
testcase_28 AC 18 ms
8,688 KB
testcase_29 AC 19 ms
8,744 KB
testcase_30 AC 29 ms
8,700 KB
testcase_31 AC 30 ms
8,728 KB
testcase_32 AC 29 ms
8,868 KB
testcase_33 AC 54 ms
8,796 KB
testcase_34 AC 57 ms
8,920 KB
testcase_35 AC 24 ms
8,852 KB
testcase_36 AC 21 ms
8,752 KB
testcase_37 AC 20 ms
8,860 KB
testcase_38 AC 20 ms
8,732 KB
testcase_39 AC 20 ms
8,844 KB
testcase_40 AC 21 ms
8,680 KB
testcase_41 AC 20 ms
8,792 KB
testcase_42 AC 20 ms
8,804 KB
testcase_43 AC 20 ms
8,872 KB
testcase_44 AC 20 ms
8,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
import functools
import itertools
import math
import operator


def factorize(n):
    step = lambda x: 1 + (x << 2) - ((x >> 1) << 1)
    maxq = int(math.floor(math.sqrt(n)))
    d = 1
    q = n % 2 == 0 and 2 or 3
    while q <= maxq and n % q != 0:
        q = step(d)
        d += 1
    return q <= maxq and [q] + factorize(n // q) or [n]


def divisors(n):
    factors = collections.Counter(factorize(n))
    ks = list(factors.keys())
    for l in itertools.product(*[range(v + 1) for v in factors.values()]):
        yield functools.reduce(operator.mul, (ks[i] ** l[i] for i in range(len(ks))))


def solve():
    N = int(input())
    ds = divisors(N)
    ds = sorted(ds)

    for d in ds:
        if d > 2 and N % d == 0:
            print(d)
            return


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