結果
問題 | No.414 衝動 |
ユーザー |
|
提出日時 | 2022-10-24 17:29:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 205 ms / 1,000 ms |
コード長 | 1,132 bytes |
コンパイル時間 | 198 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-07-02 20:15:53 |
合計ジャッジ時間 | 2,339 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 |
ソースコード
from itertools import countdef calc_positive_divisors(num: int) -> dict[int, int]:if num < 2:raise ValueErrordivisors = {}for divisor in count(2):if divisor ** 2 > num:if num != 1:divisors[num] = 1breakwhile num % divisor == 0 and num != 1:try:divisors[divisor] += 1except KeyError:divisors[divisor] = 1num //= divisorreturn divisorsdef main():M = int(input())if M == 1:print(1, 1)returnif M == 2:print(1, 2)returndivisors = calc_positive_divisors(M)if len(divisors) == 1 and divisors[list(divisors.keys())[0]] == 1:print(1, M)else:divisor = list(divisors.keys())[0]divisors[divisor] -= 1if divisors[divisor] == 0:divisors.pop(divisor)another_divisor = 1for divisor_, count_ in divisors.items():another_divisor *= divisor_ ** count_print(divisor, another_divisor)if __name__ == "__main__":main()