/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 15ms 3.062 MiB
#2 Accepted 17ms 3.117 MiB
#3 Accepted 26ms 2.887 MiB
#4 Accepted 15ms 2.957 MiB
#5 Accepted 14ms 2.988 MiB
#6 Accepted 16ms 3.047 MiB
#7 Accepted 94ms 3.113 MiB
#8 Accepted 78ms 3.109 MiB
#9 Accepted 243ms 2.926 MiB
#10 Accepted 63ms 3.074 MiB
#11 Accepted 198ms 3.023 MiB

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