結果

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

ソースコード

diff #

import sys

def main():
    input = sys.stdin.read().split()
    T = int(input[0])
    queries = list(map(int, input[1:T+1]))
    
    max_n = 10**5
    # Initialize smallest prime factors (SPF)
    spf = list(range(max_n + 1))
    for i in range(2, int(max_n**0.5) + 1):
        if spf[i] == i:  # i is a prime
            for j in range(i*i, max_n + 1, i):
                if spf[j] == j:
                    spf[j] = i
    
    # Precompute albedo values
    alb = [0] * (max_n + 1)
    for n in range(1, max_n + 1):
        if n == 1:
            alb[n] = 0
        else:
            temp = n
            product = 1
            while temp != 1:
                p = spf[temp]
                exponent = 0
                while temp % p == 0:
                    exponent += 1
                    temp //= p
                product *= (exponent // 2 + 1)
            alb[n] = product - 1
    
    # Process each query
    for q in queries:
        print(alb[q])

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