結果
| 問題 |
No.136 Yet Another GCD Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-08 00:07:05 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 5,000 ms |
| コード長 | 600 bytes |
| コンパイル時間 | 227 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-07-08 01:33:49 |
| 合計ジャッジ時間 | 2,719 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
import math
def factorize(n):
''' returns a list of prime factors of n.
ex. factorize(24) = [2, 2, 2, 3]
source: Rossetta code: prime factorization (slightly modified)
http://rosettacode.org/wiki/Prime_decomposition#Python:_Using_floating_point
'''
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]
N, K = map(int, input().split())
factors = factorize(N)
print(N // factors[0])