Submission #60533598


Source Code Expand

Copy
def countNumbers(n):
c = 0
limit = int(n ** (0.5))
# Sieve array, initially prime[i] = i
prime = [i for i in range(limit + 1)]
# use sieve concept to store the
# first prime factor of every number
i = 2
while i * i <= limit:
if prime[i] == i:
# mark all factors of i
for j in range(i * i, limit + 1, i):
if prime[j] == j:
prime[j] = i
i += 1
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
def countNumbers(n): 
     
    c = 0
    limit = int(n ** (0.5))
 
    # Sieve array, initially prime[i] = i 
    prime = [i for i in range(limit + 1)] 
     
    # use sieve concept to store the 
    # first prime factor of every number 
    i = 2
    while i * i <= limit: 
        if prime[i] == i: 
             
            # mark all factors of i 
            for j in range(i * i, limit + 1, i): 
                if prime[j] == j: 
                    prime[j] = i 
         
        i += 1
 
    # check for all numbers if they 
    # can be expressed in form p*q 
    for i in range(2, limit + 1): 
         
        # p prime factor 
        p = prime[i] 
 
        # q prime factor 
        q = prime[i // prime[i]] 
 
        # if both prime factors are different 
        # if p*q<=n and q!= 
        if p * q == i and q != 1 and p != q: 
            c += 1
         
        elif prime[i] == i: 
 
            # Check if it can be 
            # expressed as p^8 
            if i ** 8 <= n: 
                c += 1
     
    return c 
 
n = int(input())
print(countNumbers(n)) 

Submission Info

Submission Time
Task D - 9 Divisors
User Jxsh28
Language Python (CPython 3.11.4)
Score 400
Code Size 1141 Byte
Status AC
Exec Time 485 ms
Memory 87384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 34
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 9 ms 8360 KB
00_sample_02.txt AC 484 ms 87380 KB
01_test_01.txt AC 9 ms 8516 KB
01_test_02.txt AC 9 ms 8504 KB
01_test_03.txt AC 9 ms 8548 KB
01_test_04.txt AC 9 ms 8532 KB
01_test_05.txt AC 9 ms 8684 KB
01_test_06.txt AC 257 ms 52992 KB
01_test_07.txt AC 109 ms 28592 KB
01_test_08.txt AC 408 ms 77916 KB
01_test_09.txt AC 439 ms 82784 KB
01_test_10.txt AC 213 ms 46288 KB
01_test_11.txt AC 485 ms 87008 KB
01_test_12.txt AC 226 ms 49300 KB
01_test_13.txt AC 227 ms 48348 KB
01_test_14.txt AC 274 ms 55520 KB
01_test_15.txt AC 449 ms 84596 KB
01_test_16.txt AC 334 ms 67108 KB
01_test_17.txt AC 228 ms 49288 KB
01_test_18.txt AC 202 ms 44640 KB
01_test_19.txt AC 416 ms 78816 KB
01_test_20.txt AC 84 ms 24068 KB
01_test_21.txt AC 9 ms 8504 KB
01_test_22.txt AC 9 ms 8464 KB
01_test_23.txt AC 9 ms 8520 KB
01_test_24.txt AC 471 ms 87184 KB
01_test_25.txt AC 484 ms 87316 KB
01_test_26.txt AC 478 ms 87224 KB
01_test_27.txt AC 465 ms 87212 KB
01_test_28.txt AC 475 ms 87204 KB
01_test_29.txt AC 467 ms 87384 KB
01_test_30.txt AC 446 ms 82440 KB
01_test_31.txt AC 444 ms 82228 KB
01_test_32.txt AC 450 ms 82196 KB


2025-03-05 (Wed)
12:22:44 +00:00