Số phong phú

View as PDF

Submit solution


Points: 0.06 (partial)
Time limit: 0.38s
Memory limit: 256M
Input: stdin
Output: stdout

Problem source:
PTNK 10 Final Exam - Semester I, 2008
Problem types
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

Trong số học, số phong phú là các số mà tổng các ước số của số đó (không kể chính nó) lớn hơn số đó. Ví dụ, số ~12~ có tổng các ước số (không kể ~12)~ là ~1 + 2 + 3 + 4 + 6 = 16 > 12~. Do đó ~12~ là một số phong phú.

Bạn hãy lập trình đếm xem có bao nhiêu số phong phú trong đoạn ~[L~, ~R]~.

Input

  • Gồm ~2~ số ~L~, ~R~ ~(1 \le L \le R \le 10^{5})~

Output

  • Gồm ~1~ số nguyên duy nhất là số số phong phú trong đoạn ~[L~, ~R]~.

Giới hạn

  • Có ~50\%~ số test có ~1 \le L \le R \le 10^{3}~

Sample Input

1 50

Sample Output

9

Note

  • Từ ~1~ đến ~50~ có ~9~ số phong phú là: ~12~, ~18~, ~20~, ~24~, ~30~, ~36~, ~40~, ~42~, ~48~

Comments

Please read the guidelines before commenting.



  • -1
    vanh1401  commented on Nov. 10, 2025, 3:54 a.m.

    1 đấm AC


  • -1
    vominhmanh10  commented on Nov. 2, 2025, 6:07 a.m.

    thực hiện như sàng số nguyên tố, không khác gì đâu:))

    import sys
    input = sys.stdin.read
    sys.setrecursionlimit(10**7)
    
    def main(l, r):
        k = int(r ** 0.5)
        for i in range(2, k + 1):
            for j in range(i * i, r + 1, i):
                ans[j] += i
                if i * i != j: ans[j] += j // i
        res = []
        for x in range(l, r + 1):
            if ans[x] > x:
                res.append(x)
        return res
    
    data = input().split()
    l, r = map(int, data)
    ans = [1] * (r + 1)
    print(len(main(l, r)))
    

  • -14
    zatarainbow  commented on July 27, 2024, 3:13 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -5
    khnguyen21th06  commented on May 16, 2024, 9:39 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -28
    trunn  commented on Oct. 16, 2023, 2:23 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • 1
    tuattsx3  commented on Sept. 24, 2023, 2:01 p.m.

    mọi người dùng sàng ước nhá:D def sub(n): result = [1] * (n + 1)
    for i in range(2, n//2 + 1): for j in range(i * 2, n + 1, i):result[j] += i return result


  • -17
    nova  commented on Sept. 21, 2023, 8:44 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • -12
      nova  commented on Sept. 21, 2023, 9:30 a.m.

      This comment is hidden due to too much negative feedback. Show it anyway.


      • -13
        duybinh_cbl  commented on Sept. 21, 2023, 1:13 p.m.

        This comment is hidden due to too much negative feedback. Show it anyway.


        • -1
          huyleee  commented on Oct. 21, 2023, 8:20 a.m.

          em hỏi :))


  • -11
    nogo007akapkn  commented on Aug. 31, 2023, 3:13 p.m. edit 3

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -34
    dhduong04  commented on Jan. 25, 2022, 8:24 a.m. edited

    This comment is hidden due to too much negative feedback. Show it anyway.