結果

問題 No.2751 429-like Number
ユーザー mottchanmottchan
提出日時 2024-05-10 23:41:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,735 ms / 4,000 ms
コード長 746 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 82,028 KB
実行使用メモリ 77,508 KB
最終ジャッジ日時 2024-05-10 23:41:55
合計ジャッジ時間 22,283 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
60,672 KB
testcase_01 AC 50 ms
60,316 KB
testcase_02 AC 51 ms
61,580 KB
testcase_03 AC 58 ms
62,220 KB
testcase_04 AC 55 ms
60,944 KB
testcase_05 AC 54 ms
60,632 KB
testcase_06 AC 60 ms
61,768 KB
testcase_07 AC 837 ms
77,340 KB
testcase_08 AC 132 ms
74,084 KB
testcase_09 AC 1,421 ms
73,256 KB
testcase_10 AC 1,564 ms
72,528 KB
testcase_11 AC 1,690 ms
76,784 KB
testcase_12 AC 839 ms
76,980 KB
testcase_13 AC 1,728 ms
77,292 KB
testcase_14 AC 1,735 ms
76,964 KB
testcase_15 AC 108 ms
74,176 KB
testcase_16 AC 810 ms
77,340 KB
testcase_17 AC 895 ms
77,508 KB
testcase_18 AC 837 ms
77,044 KB
testcase_19 AC 804 ms
77,452 KB
testcase_20 AC 823 ms
77,404 KB
testcase_21 AC 827 ms
77,028 KB
testcase_22 AC 805 ms
76,988 KB
testcase_23 AC 844 ms
77,296 KB
testcase_24 AC 833 ms
77,096 KB
testcase_25 AC 804 ms
77,168 KB
testcase_26 AC 853 ms
77,180 KB
testcase_27 AC 846 ms
77,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def get_prime(n):
    sieve = [True] * (n + 1) 
    i = 2
    while i * i <= n: 
        if sieve[i]:
            for j in range(i * i, n + 1, i):
                sieve[j] = False
        i += 1
    return [i for i in range(2, n + 1) if sieve[i]]

q = int(input())
l = get_prime(100000)

for _ in range(q):
    n = int(input())
    cnt=0
    idx=0
    while cnt < 3 and idx < len(l):
        if n%l[idx] ==0:
            cnt+=1
            n //= l[idx]
        else:
            idx += 1

    if cnt == 3:
        if n == 1:
            print('Yes')
        else:
            print('No')
    elif cnt == 2:
        if n == 1:
            print('No')
        else:
            # print(n)
            print('Yes')
    else:
        print('No')
    
0