THAY ĐỔI CHỮ SỐ

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
    khoasadnhan   commented on April 15, 2025, 9:26 p.m.

    from itertools import combinations, product

    def is_valid(s): return s[0] != '0' and int(s[-2:]) % 4 == 0

    def smallestdivisibleby4(N): Nstr = str(N) length = len(Nstr) minnum = None

    for k in range(3):  
        for positions in combinations(range(length), k):  
            digits_choices = [list("0123456789") if i in positions else [N_str[i]] for i in range(length)]
            for candidate_digits in product(*digits_choices):
                candidate = ''.join(candidate_digits)
                if is_valid(candidate):
                    if min_num is None or int(candidate) < int(min_num):
                        min_num = candidate
    
    return min_num
    

    N = int(input()) print(smallestdivisibleby_4(N))


  • 0
    hainam4b   commented on April 14, 2025, 4:16 p.m.

    nhìn gì


  • -1
    phambahuy5ddl   commented on April 11, 2025, 5:14 p.m.

    hello


  • -1
    phambahuy5ddl   commented on April 11, 2025, 5:12 p.m.

    eeeeee


  • 0
    phambahuy5ddl   commented on April 11, 2025, 5:12 p.m.

    nguyên


  • -1
    nguyentrungnguyen5ddl   commented on April 11, 2025, 5:10 p.m. edited

    1//1//1/1/11//1/1 khó


  • -1
    nguyentrungnguyen5ddl   commented on April 11, 2025, 5:08 p.m. edited

    1\


  • -1
    nguyentrungnguyen5ddl   commented on April 11, 2025, 5:08 p.m. edited

    khó quá có ai vhir ko


  • -1
    nguyentrungnguyen5ddl   commented on April 11, 2025, 5:08 p.m.

    b evdfcaeb


  • -1
    leducanh5b_thqp2   commented on April 10, 2025, 2:08 p.m. edit 2

    .


  • -1
    phamngocthai   commented on March 26, 2025, 3:42 p.m. edit 2

    :0


  • -1
    Meoxin1138E   commented on Nov. 29, 2024, 5:55 p.m.

    duybaothcq


  • -5
    Meoxin1138E   commented on Nov. 29, 2024, 5:55 p.m.

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


  • -1
    tinhoctretqc   commented on Nov. 13, 2024, 3:57 p.m.

    có bạn nào giải scratch cho xin tham khảo với,xin cảm ơn


  • -1
    SK24_A560   commented on July 29, 2024, 11:23 a.m.

    code python cho ai bí idea: n = int(input()) s = list(map(int, str(n))) if len(s) > 2: k = 2 if n % 4 != 0: if n % 2 == 0: s[len(s) - 2] = 0 if s[len(s) - 1] % 4 == 0 else 1 else: s[len(s) - 1] = 0 if s[len(s) - 2] % 2 == 0 else 1 k -= 1 i = 1 if s[0] != 1: s[0] = 1 k -= 1 while k > 0 and i < len(s): if s[i] != 0: s[i] = 0 k -= 1 i += 1 print("".join([str(x) for x in s])) elif len(s) == 2: print(12) else: print(0)


  • -1
    thienthansanga2k13   commented on July 5, 2024, 9:09 a.m.

    Có bạn nào có code của scratch không? chỉ mik với, mình làm bị sai hoài à T^T Mắc kẹt ở bài này hơn 5 ngày rồi


  • 2
    tanpahtth   commented on May 28, 2024, 8:03 p.m. edit 2

    solve: https://codebeautify.org/alleditor/y240053b6


  • -5
    lolphjwgfy4   commented on May 9, 2024, 10:12 p.m.

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


    • 11
      admin   commented on May 10, 2024, 8:17 a.m.

      Bạn có thể cung cấp thêm thông tin về tình trạng tài khoản bị người xấu sử dụng thông qua email của Ban Tổ chức Hội thi tại tainangviet.twd@gmail.com để được xem xét. Trân trọng cảm ơn.


  • -13
    truongphat   commented on May 8, 2024, 7:13 p.m.

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


  • -5
    truongphat   commented on May 8, 2024, 7:12 p.m.

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


  • -4
    CLMOKJS   commented on May 8, 2024, 1:16 p.m. edited

    ACC duybaothcq của tôi tự nhiên bị khoá tôi không làm gì hết có thằng tự nhiên vào acc phá tôi nhá admin hãy trả lại acc cho tôi được không?


    • 12
      admin   commented on May 8, 2024, 2:09 p.m.

      Bạn có thể cung cấp thêm thông tin về tình trạng tài khoản bị người xấu sử dụng thông qua email của Ban Tổ chức Hội thi tại tainangviet.twd@gmail.com để được xem xét. Trân trọng cảm ơn.


  • -1
    khanhngocc1   commented on May 7, 2024, 6:27 p.m.

    ai bt làm ko cứu tui


  • 8
    anhtuthcq   commented on May 7, 2024, 4:04 p.m.

    ai biết làm không vậy


    • 1
      doanngocgiahung_2004   commented on May 24, 2024, 8:43 p.m.

      tui biết , cần code python không tôi gửi cho


      • -4
        DucKien2014   commented on June 29, 2024, 4:13 p.m.

        Tui


        • -2
          tranquocdat2k13   commented on July 4, 2024, 8:34 a.m.

          def xuli(s, pos, kitu): sy = s[pos + 1:]; sx = s[:pos]; return sx + str(kitu) + sy; s = input(); n = len(s) s1 = s; res = 10**18; for i in range(1, 10): s1 = xuli(s1, 0, i) temp = s1; for j in range(1, n): s1 = temp; for k in range(10): s1 = xuli(s1, j, k); if int(s1) % 4 == 0: res = min(res, int(s1)); s1 = s; for t in range(1, n): s1 = s; for i in range(10): s1 = xuli(s1, t, i) temp = s1; for j in range(1, n): s1 = temp; for k in range(10): if int(s1) % 4 == 0: res = min(res, int(s1)); s1 = xuli(s1, j, k); print(res)


  • 3
    anhtuthcq   commented on May 7, 2024, 4:04 p.m.

    ai biết làm không vậy


  • 4
    anhtuthcq   commented on May 7, 2024, 4:04 p.m.

    hi


  • -2
    anhtuthcq   commented on May 7, 2024, 4:03 p.m.

    xin chào


  • -26
    duybaothcq   commented on May 7, 2024, 7:31 a.m. edited

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


  • -4
    anhtuthcq   commented on May 5, 2024, 8:54 a.m. edited

    làm thế nào vậy


  • -33
    duybaothcq   commented on May 4, 2024, 9:01 p.m.

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


  • -27
    anhducthcq   commented on May 3, 2024, 4:34 p.m.

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


  • -33
    anhducthcq   commented on May 3, 2024, 4:34 p.m.

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


  • -24
    anhducthcq   commented on May 3, 2024, 4:34 p.m.

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


  • -30
    anhducthcq   commented on May 3, 2024, 4:30 p.m.

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