A. Parking … Simple comparison with if

1 2 3 |
n, a, b = list(map(int, input().split())) print(a*n if b > a*n else b) |

B. Harshard Number … Given one number, and judge if the number is Harshard Number. use modulus.

1 2 3 4 5 |
x = input() fx = sum([int(num) for num in x]) print("Yes" if int(x)%fx == 0 else "No") |

C. Shopping Street … Given one number, and two lists. And calculate the highest profit we can earn.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
n = int(input()) f = [] for _ in range(n): f.append(list(map(int, input().split()))) p = [] for _ in range(n): p.append(list(map(int, input().split()))) result = -float("inf") # opening schedule for my shop. # start from 1(only open Mon.AM) to 1023(open all day) for b in range(1, 1<<10): profit = 0 # compare with other shops for i in range(n): common_opening = 0 # compare time for j in range(10): if 1&(b>>j) and f[i][j] == 1: common_opening += 1 profit += p[i][common_opening] result = max(result, profit) print(result) |