結果

問題 No.136 Yet Another GCD Problem
ユーザー daleksprinter
提出日時 2018-08-16 13:39:53
言語 Python2
(2.7.18)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 491 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-10-01 21:14:45
合計ジャッジ時間 1,519 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False

    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


n,k = map(int,raw_input().split())

if is_prime(n):
    print 1
    quit()

i = 2
while i**2 <= n:
    if n % i == 0:
        print n/i
        quit()
    i += 1
0