TÍNH TỔNG

View as PDF

Submit solution

Points: 100.00 (partial)
Time limit: 1.0s
Memory limit: 512M
Input: stdin
Output: stdout

Problem type
Allowed languages
Python, Scratch

In case the statement didn't load correctly, you can download the statement here: Statement


Comments

Please read the guidelines before commenting.



  • 0
    O_long   commented on Jan. 7, 2025, 11:02 p.m.

    cho bn nào ko bt


  • 0
    O_long   commented on Jan. 7, 2025, 11:02 p.m.

    def sumevennotdivisibleby3(A, B): def sumofarithmeticsequence(start, end, step): count = (end - start) // step + 1 return count * (start + (count - 1) * step // 2)

    # Tìm tổng các số chẵn từ A+1 đến B-1
    start = (A // 2 + 1) * 2
    end = (B - 1) // 2 * 2
    if start > end:
        return 0
    total_sum_even = sum_of_arithmetic_sequence(start, end, 2)
    
    # Tìm tổng các số chẵn chia hết cho 6 từ A+1 đến B-1
    start = ((A // 6) + 1) * 6
    end = (B - 1) // 6 * 6
    if start > end:
        total_sum_six = 0
    else:
        total_sum_six = sum_of_arithmetic_sequence(start, end, 6)
    
    return total_sum_even - total_sum_six
    

    Đọc đầu vào

    A = int(input()) B = int(input())

    Tính tổng các số X thỏa mãn điều kiện

    result = sumevennotdivisibleby_3(A, B)

    In kết quả

    print(result)


  • 1
    Hoang_Linh   commented on July 4, 2024, 9:29 p.m. edit 2

    Full code python nhé (5/5):

    https://codebeautify.org/alleditor/y24a968b5


  • 0
    tn   commented on July 3, 2024, 10:30 p.m.

    code: https://codebeautify.org/alleditor/y2426ef6b


  • 0
    HDG_12   commented on July 2, 2024, 5:28 p.m.

    toàn bị quá thời gian cái cuối


  • -1
    thienthansanga2k13   commented on June 27, 2024, 10:50 a.m. edited

    mik làm bên scratch, cứ bị quá thời gian test 5


  • 0
    SK24_D167   commented on June 16, 2024, 12:37 p.m.

    Mình bị quá thời gian đúng test cuối luôn á


  • 0
    LOADING   commented on May 17, 2024, 7:58 p.m. edited

    Giúp mình với help


    • 0
      TuanPhong_scratch   commented on Dec. 21, 2024, 4:21 p.m.

      ko có đâu test ghi vậy thôi chứ bạn sai đó


    • 0
      newbie_GM   commented on July 5, 2024, 11:15 p.m.

      Dream thi tin hoc tre =))


  • 0
    LOADING   commented on May 17, 2024, 7:58 p.m.

    Sao câu cuối cùng mình quá thời gian vậy ạ


  • -1
    lam2013   commented on May 9, 2024, 8:32 a.m.

    bài dễ


  • -13
    anhducthcq   commented on May 5, 2024, 8:44 a.m.

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


  • -11
    anhducthcq   commented on May 5, 2024, 8:44 a.m.

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


  • -11
    anhducthcq   commented on May 5, 2024, 8:44 a.m.

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