Project Euler #31: Coin sums

  • + 0 comments

    Took me 2 minutes to solve it 100/- Python3:

    MOD = 10**9 + 7
    
    def calculate_combinations(limit, multiples):
        lis = [0] * (limit + 1)
        lis[0] = 1
    
        for i in multiples:
            for n in range(limit - i + 1):
                lis[n + i] += lis[n]
                lis[n + i] %= MOD
    
        return lis
    
    no = 10**5
    multiples = [1, 2, 5, 10, 20, 50, 100, 200]
    
    lis = calculate_combinations(no, multiples)
    
    for _ in range(int(input())):
        n = int(input())
        print(lis[n] % MOD)