結果

問題 No.36 素数が嫌い!
ユーザー yaoshimaxyaoshimax
提出日時 2015-02-21 16:24:47
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 6,676 KB
実行使用メモリ 257,068 KB
最終ジャッジ日時 2023-09-06 02:55:31
合計ジャッジ時間 80,144 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,494 ms
256,940 KB
testcase_01 AC 2,487 ms
256,912 KB
testcase_02 AC 2,492 ms
256,944 KB
testcase_03 AC 2,493 ms
257,028 KB
testcase_04 WA -
testcase_05 AC 2,476 ms
256,992 KB
testcase_06 AC 2,501 ms
257,048 KB
testcase_07 AC 2,489 ms
257,028 KB
testcase_08 AC 2,498 ms
256,896 KB
testcase_09 AC 2,507 ms
257,016 KB
testcase_10 AC 2,487 ms
257,068 KB
testcase_11 AC 2,552 ms
256,808 KB
testcase_12 AC 2,639 ms
256,912 KB
testcase_13 WA -
testcase_14 AC 2,501 ms
256,944 KB
testcase_15 AC 2,505 ms
256,964 KB
testcase_16 AC 2,492 ms
256,840 KB
testcase_17 AC 2,503 ms
256,900 KB
testcase_18 AC 2,499 ms
256,892 KB
testcase_19 AC 2,551 ms
256,896 KB
testcase_20 AC 2,503 ms
257,016 KB
testcase_21 AC 2,576 ms
256,808 KB
testcase_22 AC 2,511 ms
256,944 KB
testcase_23 AC 2,492 ms
257,052 KB
testcase_24 AC 2,518 ms
257,064 KB
testcase_25 AC 2,496 ms
256,940 KB
testcase_26 AC 2,547 ms
256,880 KB
testcase_27 AC 2,504 ms
256,880 KB
testcase_28 AC 2,560 ms
256,872 KB
testcase_29 AC 2,499 ms
257,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# I hate Math
N=int(raw_input())
upperbound=10000001
isOKsize=(upperbound-3)/2+1
isOK=[True for i in range(isOKsize)]

for i in range(isOKsize):
    if (i+i+3)*i+i > isOKsize:
        break
    if isOK[i]:
        #i+i+3 is prime
        p=i+i+3
        #delete j s.t. j+j+3 = (2i+3)^2 = 4i^2+12i+9 => j=2i^2+6i+3=p*(i+1)+i
        #next j is j+j+3 = (2i+3)(2i+5). that is, step of j is 2i+3=p
        for k in range( p*i+p+i, isOKsize, p):
            isOK[k]=False
primes = [2] + [i+i+3 for i in range(isOKsize) if isOK[i]]

cnt = 0
for p in primes:
    #print p
    if p*p > N:
        break
    while cnt<2 and N%p==0:
        cnt+=1
        N/=p
    if cnt >= 2:
        break
if cnt>=2:
    print "YES"
else:
    print"NO"

0