結果

問題 No.1022 Power Equation
ユーザー stngstng
提出日時 2020-04-12 10:06:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,184 bytes
コンパイル時間 666 ms
コンパイル使用メモリ 12,080 KB
実行使用メモリ 10,564 KB
最終ジャッジ日時 2023-10-22 00:54:34
合計ジャッジ時間 4,760 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

t = int(input())
ni = [int(input()) for i in range(t)]

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

#print(int((10**9+100)**0.5)+1)

pri_li = primes(int((10**9)**0.5)+1)

for i in range(t):
    n_num = ni[i]
    ans = 0
    for j in range(len(pri_li)):
        pri_num = pri_li[j]
        if pri_num > n_num:
            break
        for k in range(1,n_num+1):
            if k > n_num:
                break
            else:
                tmp = 0
                for l in range(1,k+1):
                    #print(pri_num,k,l,tmp)
                    if k % l == 0:
                        if pri_num**l > n_num:
                            break
                        tmp += 1
                if tmp <= 1:
                    continue
                #print(ans)
                ans += math.factorial(tmp)
                #print(pri_num,k,l,tmp,ans)
    #print(ans)
    print(ans+n_num*(2*n_num-1))
0