結果

問題 No.3079 Unite Japanese Prefectures
ユーザー gew1fw
提出日時 2025-06-12 18:58:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 745 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 82,072 KB
実行使用メモリ 60,524 KB
最終ジャッジ日時 2025-06-12 18:58:36
合計ジャッジ時間 2,150 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    T = int(input[0])
    cases = list(map(int, input[1:T+1]))
    
    max_n = max(cases)
    spf = list(range(max_n + 1))
    for i in range(2, int(max_n**0.5) + 1):
        if spf[i] == i:
            for j in range(i*i, max_n+1, i):
                if spf[j] == j:
                    spf[j] = i
    
    def get_sum(n):
        if n == 1:
            return 0
        s = 0
        while n != 1:
            p = spf[n]
            cnt = 0
            while n % p == 0:
                cnt += 1
                n = n // p
            s += cnt
        return s
    
    res = [get_sum(n) for n in cases]
    print('\n'.join(map(str, res)))

if __name__ == "__main__":
    main()
0