白駿5585号Python


グレースケールアルゴリズム
n=int(input())
n=1000-n
result=0
while 1:
    if n==0 :
        print(result)
        break
    if n >=500 :
        temp=n//500
        result+=temp
        n-=temp*500
    elif n>=100 and n<500:
        temp=n//100
        result+=temp
        n-=temp*100
    elif n>=50 and n<100:
        temp=n//50
        result+=temp
        n-=temp*50
    elif n>=10 and n<50 :
        temp=n//10
        result+=temp
        n-=temp*10
    elif n>=5 and n<10 :
        temp=n//5
        result+=temp
        n-=temp*5
    else :
        result+=n
        n=0