結果

問題 No.1514 Squared Matching
ユーザー brthyyjpbrthyyjp
提出日時 2021-05-22 19:21:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,065 ms / 4,000 ms
コード長 971 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 450,176 KB
最終ジャッジ日時 2024-04-19 01:01:56
合計ジャッジ時間 34,871 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
59,392 KB
testcase_01 AC 2,065 ms
449,536 KB
testcase_02 AC 49 ms
59,392 KB
testcase_03 AC 49 ms
59,520 KB
testcase_04 AC 46 ms
59,264 KB
testcase_05 AC 54 ms
61,312 KB
testcase_06 AC 77 ms
67,712 KB
testcase_07 AC 419 ms
137,856 KB
testcase_08 AC 1,790 ms
435,328 KB
testcase_09 AC 1,584 ms
388,608 KB
testcase_10 AC 1,715 ms
416,096 KB
testcase_11 AC 1,789 ms
430,848 KB
testcase_12 AC 1,902 ms
441,216 KB
testcase_13 AC 1,875 ms
446,208 KB
testcase_14 AC 1,889 ms
448,128 KB
testcase_15 AC 1,897 ms
448,896 KB
testcase_16 AC 1,958 ms
449,536 KB
testcase_17 AC 2,004 ms
449,408 KB
testcase_18 AC 1,880 ms
449,536 KB
testcase_19 AC 1,953 ms
449,920 KB
testcase_20 AC 1,965 ms
450,176 KB
testcase_21 AC 1,915 ms
449,664 KB
testcase_22 AC 438 ms
141,268 KB
testcase_23 AC 816 ms
219,904 KB
testcase_24 AC 1,202 ms
293,760 KB
testcase_25 AC 1,585 ms
371,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():

    n = int(input())

    table = [i for i in range(n+1)]

    import math

    def sieve(n):
        ass = []
        is_prime = [True]*(n+1)
        is_prime[0] = False
        is_prime[1] = False

        for i in range(2, int(math.sqrt(n))+1):
            if not is_prime[i]:
                continue
            for j in range(i*2, n+1, i):
                is_prime[j] = False
        for i in range(n+1):
            if is_prime[i]:
                ass.append(i)
        return(ass)

    S = sieve(7500)

    for p in S:
        t = p**2
        for i in range(2, 34):
            if i%2 == 1:
                continue
            j = pow(p, i)
            if j > n:
                break
            k = j
            while k <= n:
                table[k] //= t
                k += j
    #print(table)
    ans = 0
    for a in range(1, n+1):
        ans += math.floor(math.sqrt(n/table[a]))
    print(ans)
    
if __name__ == '__main__':
    main()
0