Accepted
Code
cnt = 10000000000
ok = False
X,a,b,c,n=map(int,input().split())
x=n//a +1
y=n//b +1
z=n//c +1
for i in range(x+1):
for j in range(y+1):
for k in range(z+1):
if(a*i+b*j+c*k+X == n):
ok=True
cnt=min(cnt,i+j+k)
if(ok):
print("YES")
print(cnt)
else:
print("NO")
Information
- Submit By
- Type
- Submission
- Problem
- P1028 Magical box and spell
- Language
- Python 3 (Python 3.12.3)
- Submit At
- 2024-02-01 17:26:55
- Judged At
- 2024-11-11 03:43:25
- Judged By
- Score
- 100
- Total Time
- 243ms
- Peak Memory
- 3.117 MiB