Submission #14745136


Source Code Expand

Copy
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def prime_table(N):
    is_prime = np.zeros(N, np.int64)
    is_prime[2:3] = 1
    is_prime[3::2] = 1
    for p in range(3, N, 2):
        if p * p >= N:
            break
        if is_prime[p]:
            is_prime[p * p::p + p] = 0
    return is_prime, np.where(is_prime)[0]

def main(N, primes):
    div = np.ones(N + 1, dtype=np.int64)
    for p in primes:
        for i in range(N // p + 1):
            div[p * i] += div[i]
    div *= np.arange(N + 1)
    return div.sum()

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, i8[:]))
    cc.compile()

from my_module import main

N = int(read())
is_prime, primes = prime_table(N + 1)
print(main(N, primes))

Submission Info

Submission Time
Task D - Sum of Divisors
User maspy
Language Python (3.8.2)
Score 400
Code Size 1059 Byte
Status
Exec Time 791 ms
Memory 266304 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 400 / 400 hand_01.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, sample_01.txt, sample_02.txt, sample_03.txt, sq_01.txt, sq_02.txt, sq_03.txt, sq_04.txt, sq_05.txt, sq_06.txt
Case Name Status Exec Time Memory
hand_01.txt 130 ms 26892 KB
random_01.txt 791 ms 266304 KB
random_02.txt 626 ms 216104 KB
random_03.txt 774 ms 266124 KB
random_04.txt 431 ms 145984 KB
random_05.txt 774 ms 265756 KB
random_06.txt 344 ms 114988 KB
random_07.txt 770 ms 265996 KB
random_08.txt 511 ms 175272 KB
random_09.txt 770 ms 266184 KB
random_10.txt 171 ms 51640 KB
sample_01.txt 132 ms 26860 KB
sample_02.txt 122 ms 26940 KB
sample_03.txt 766 ms 266144 KB
sq_01.txt 775 ms 266040 KB
sq_02.txt 782 ms 265824 KB
sq_03.txt 766 ms 265920 KB
sq_04.txt 774 ms 266232 KB
sq_05.txt 772 ms 265920 KB
sq_06.txt 774 ms 266120 KB