1 条题解

  • 0
    @ 2025-8-21 0:17:09
    from math import sqrt,ceil,gcd,log;re=lambda:map(int,input().split())
    def solve():
        n, a, b = re()
    
        x = [1, 2, 5, 10, 20, 50, 100]
        y = [5, 10, 20, 50, 100, 200]
    
        costs = set()
    
        for i in x:
            cost = i * a
            if cost <= n:
                costs.add(cost)
    
        for i in y:
            cost = i * b
            if cost <= n:
                costs.add(cost)
      
        dp = [False] * (n + 1)
        dp[0] = True
    
        for cost in costs:
            for j in range(cost, n + 1):
                dp[j] |= dp[j - cost]
    
    
        for i in range(n, -1, -1):
            if dp[i]:
                print(n - i)
                return
    
    solve()
    
    • 1

    信息

    ID
    392
    时间
    1000ms
    内存
    128MiB
    难度
    9
    标签
    (无)
    递交数
    20
    已通过
    3
    上传者