Problem:


 おつり 

問題

太郎君はよくJOI雑貨店で買い物をする． JOI雑貨店には硬貨は500円，100円，50円，10円，5円，1円が十分な数だけあり，いつも最も枚数が少なくなるようなおつりの支払い方をする．太郎君がJOI雑貨店で買い物をしてレジで1000円札を1枚出した時，もらうおつりに含まれる硬貨の枚数を求めるプログラムを作成せよ．

例えば入力例1の場合は下の図に示すように，4を出力しなければならない． 

入力

入力は複数のデータセットからなる．各データセットは1行からなり，太郎君が支払う金額（1以上1000未満の整数）が1つだけ書かれている．入力データはゼロ１つの行で終了する．

データセットの数は 5 を超えない．

出力

データセットごとにおつりに含まれる硬貨の枚数を1行に出力せよ．

入出力例

入力例

380
1
0

出力例

4
15

上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。



Sample input:
380
1
0


Sample output:
4
15

Submission status: Accepted

Solution code:
x = int(input())
while x != 0:
    y = 1000 - x
    a = y // 500
    A = y % 500
    b = A // 100
    B = A % 100
    c = B // 50
    C = B % 50
    d = C // 10
    D = C % 10
    e = D // 5
    E = D % 5
    print(a + b + c + d + e + E)
    x = int(input())

Submission status: Accepted

Solution code:
def main():
    while True:
        s = int(input())
        if s == 0:
            break
        cnt = 0
        s = 1000 - s
        if s//500 != 0:
            cnt += s//500
            s %= 500
        if s//100 != 0:
            cnt += s//100
            s %= 100
        if s//50 != 0:
            cnt += s//50
            s %= 50
        if s//10 != 0:
            cnt += s//10
            s %= 10
        if s//5 != 0:
            cnt += s//5
            s %= 5
        if s//1 != 0:
            cnt += s//1
            s %= 1
        print(cnt)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
while True:
    t = int(input())
    if t==0:
        break
    n = (1000-t)//500+((1000-t)%500)//100+((1000-t)%100)//50+((1000-t)%50)//10+((1000-t)%10)//5+((1000-t)%5)
    print(n)

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    if x == 0:
        break
    a=(1000-x)//500
    b=(1000-x)%500//100
    c=(1000-x)%500%100//50
    d=(1000-x)%500%100%50//10
    e=(1000-x)%500%100%50%10//5
    f=(100-x)%500%100%50%10%5
    print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
while True:
    m=int(input())
    p=1000-m
    a=p//500
    x=p%500
    b=x//100
    y=x%100
    c=y//50
    z=y%50
    d=z//10
    o=z%10
    e=o//5
    f=o%5
    if m==0:
        break
    print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
while True:
    money=int(input())
    
    if money==0:
        break
    
    a=1000-money
    A=a//500
    b=a-500*A
    B=b//100
    c=b-100*B
    C=c//50
    d=c-50*C
    D=d//10
    e=d-D*10
    E=e//5
    F=e-E*5
    
    print(A+B+C+D+E+F)

Submission status: Accepted

Solution code:
for i in range(5):
  x=int(input())
  if x==0:break
  else:
    s=1000-x
    a=s//500
    a1=s-a*500
    b=a1//100
    b1=a1-b*100
    c=b1//50
    c1=b1-c*50
    d=c1//10
    d1=c1-d*10
    e=d1//5
    f=d1-e*5
    sum=a+b+c+d+e+f
  print(sum)

Submission status: Accepted

Solution code:
while True:
  x = int(input())
  if x == 0:
      break
  n = 0
  m = 1000 - x
  for i in [500,100,50,10,5,1]:
    n += m // i
    m = m % i
  print(n)

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    if x == 0:
        break
    m=1000-x
    s=0
    if m >= 500:
        s += 1
        m -=500
    while m >= 100:
        s += 1
        m -= 100
    if m >= 50:
        s += 1
        m -= 50
    while m >= 10:
        s += 1
        m -= 10
    if m >= 5:
        s += 1
        m -= 5
    while m >= 1:
        s += 1
        m -= 1
    print(s)

Submission status: Accepted

Solution code:
while True:
    a = int(input())
    if a == 0:break

    kozeni = [500,100,50,10,5,1]
    a= 1000 - a
    ans = 0
    for b in kozeni:
        ans+=a // b
        a%=b
    print(ans)

Submission status: Accepted

Solution code:
for i in range(5):
    e  = int(input())
    if e == 0:
        break
    e500 = (1000 - e)//500
    e100 = (1000 - e)%500//100
    e50 = (1000 - e)%500%100//50
    e10 = (1000 - e)%500%100%50//10
    e5 = (1000 - e)%500%100%50%10//5
    e1 = (1000 - e)%500%100%50%10%5//1
    print(e500+e100+e50+e10+e5+e1)

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    if x==0:
        break

    else: 
        otsuri=1000-x;
        a=otsuri%500
        b=a%100
        c=b%50
        d=c%10
        e=d%5
        maisuu=otsuri//500+a//100+b//50+c//10+d//5+e
        print(maisuu)

Submission status: Accepted

Solution code:
while True:
   x = int(input())
   if x == 0:
      break
   
   y = 1000 - x;
   a = y % 500
   b = a % 100
   c = b % 50
   d = c % 10
   e = d % 5
   z = y // 500 + a // 100 + b // 50 + c // 10 + d // 5 + e
   
   print(z)

Submission status: Accepted

Solution code:
while True:
    m=int(input())
    p=1000-m
    a=p//500
    x=p%500
    b=x//100
    y=x%100
    c=y//50
    z=y%50
    d=z//10
    o=z%10
    e=o//5
    f=o%5
    if m==0:
        break
    print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

while True:
    a = int(input())
    if a == 0 :
        break
    b = 1000 - a
    c = b //500
    d = b % 500
    e = d //100
    f = d % 100
    g = f //50
    h = f % 50
    i = h //10
    j = h %10
    k = j //5
    l = j %5
    print(c+e+g+i+k+l)

Submission status: Accepted

Solution code:
while True:
    bill = int(input())
    change = 0
    if bill == 0:
        break
    else:
        pay = 1000 - bill
        for i in [500, 100, 50, 10, 5, 1]:
            change += pay // i
            pay %= i
    print(change)

Submission status: Accepted

Solution code:
while True :
    n = int(input())
    if n == 0 :
        break
    
    s = 1000 - n
    count = 0
    if s >= 500 :
        count += 1
        s = s - 500
    if s >= 100 :
        count += int(s / 100)
        s = int(s % 100)
    if s >= 50 :
        count += 1
        s = s - 50
    if s >= 10 :
        count += int(s / 10)
        s = int(s % 10)
    if s >= 5 :
        count += 1
        s = s - 5
    count += s
    print(count)

Submission status: Accepted

Solution code:
while True:
    m=int(input())
    p=1000-m
    y500=p//500
    x500=p%500
    y100=x500//100
    x100=x500%100
    y50=x100//50
    x50=x100%50
    y10=x50//10
    x10=x50%10
    y5=x10//5
    x5=x10%5
    if m==0:
        break
    print(y500+y100+y50+y10+y5+x5)

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    if x==0:
        break

    y=1000-x;
    a=y%500
    b=a%100
    c=b%50
    d=c%10
    e=d%5
    z=y//500+a//100+b//50+c//10+d//5+e
    print(z)

Submission status: Accepted

Solution code:
while True:
    i=int(input())
    if i==0:
        break
    s1=(1000-i)//500
    s2=(1000-i)%500//100
    s3=(1000-i)%500%100//50
    s4=(1000-i)%500%100%50//10
    s5=(1000-i)%500%100%50%10//5
    s6=(1000-i)%500%100%50%10%5//1
    print(s1+s2+s3+s4+s5+s6)

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    y=1000-x
    a=y//500
    b=(y-500*a)//100
    c=(y-500*a-100*b)//50
    d=(y-500*a-100*b-50*c)//10
    e=(y-500*a-100*b-50*c-10*d)//5
    f=(y-500*a-100*b-50*c-10*d-5*e)//1
    n=a+b+c+d+e+f
    if x==0:
        break
    
    print(n)

Submission status: Accepted

Solution code:
while True:
    money=int(input())
    if money==0:
        break
    n=1000-money
    a=n//500
    b=(n%500)//100
    c=(n%500%100)//50
    d=(n%500%100%50)//10
    e=(n%500%100%50%10)//5
    f=(n%500%100%50%10%5)//1
    print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n>0:
        x=1000-n
        a=x//500
        b=(x%500)//100
        c=(x%100)//50
        d=(x%50)//10
        e=(x%10)//5
        f=x%5
        print(a+b+c+d+e+f)
    else:
        break

Submission status: Accepted

Solution code:
while True:
    X=int(input())
    if X>0:
        x=1000-X
        a=x//500
        b=x%500//100
        c=x%500%100//50
        d=x%500%100%50//10
        e=x%500%100%50%10//5
        f=x%500%100%50%10%5
        print(a+b+c+d+e+f)
    else:
        break

Submission status: Accepted

Solution code:
coin=[500,100,50,10,5,1]
while True:
	a = 1000-int(input())
	if a == 1000: break
	ans = 0
	for i in coin:
		ans += a // i
		a %= i 
	print(ans)

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    if x==0:
        break
    a=1000-x
    b=a//500
    c=a%500
    d=c//100
    e=c%100
    f=e//50
    g=e%50
    h=g//10
    i=g%10
    j=i//5
    k=i%5
    print(b+d+f+h+j+k)

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    if x==0:
        break
    y=1000-x;
    a=y%500
    b=a%100
    c=b%50
    d=c%10
    e=d%5
    z=y//500+a//100+b//50+c//10+d//5+e
    print(z)

Submission status: Accepted

Solution code:
while True:
    N=int(input())
    s=0
    if N==0:
        break
    else:
        M=1000-N
        a=M//500
        b=(M-500*a)//100
        c=(M-500*a-100*b)//50
        d=(M-500*a-100*b-50*c)//10
        e=(M-500*a-100*b-50*c-10*d)//5
        f=M-500*a-100*b-50*c-10*d-5*e
        print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    charge = 1000 - n
    
    if n == 0:
        break

    count_coin = 0
    coin_kind =[1,5,10,50,100,500]

    for i in range(1,7):
        t = charge // coin_kind[-i]
        charge -= t * coin_kind[-i]
        count_coin += t

    print(count_coin)

Submission status: Accepted

Solution code:
coin = [500, 100, 50, 10, 5, 1]
while True:
	m = 1000-int(input())
	if m == 1000: break
	ans = 0
	for i in coin:
		ans += m // i
		m %= i 
	print(ans)

Submission status: Accepted

Solution code:
while True:
    P = int(input())
    if P == 0:
        break
    
    r = 1000 - P
    
    _500 = r // 500
    _100 = (r % 500) // 100
    _50 = (r % 100) // 50
    _10 = (r % 50) // 10
    _5 = (r % 10) // 5
    _1 = (r % 5)
    
    print(_500+_100+_50+_10+_5+_1)

Submission status: Accepted

Solution code:
while True:
    money=int(input())
    
    if money>0:
        oturi=1000-money
        a=oturi//500
        aa=oturi-a*500
        b=aa//100
        bb=aa-b*100
        c=bb//50
        cc=bb-c*50
        d=cc//10
        dd=cc-d*10
        e=dd//5
        ee=dd-e*5
        f=ee
        print(a+b+c+d+e+f)
    
    else:
        break

Submission status: Accepted

Solution code:
import math
c=[500,100,50,10,5,1]
while True:
    m=1000-int(input())
    if m == 1000:break
    x=0
    for i in c:
        x += m // i
        m %= i
    print(x)

Submission status: Accepted

Solution code:
i=0
l = [int(input()) for _ in range(5)]
while i<5:
    if(l[i]==0):
        break
    else:    
        a=1000-l[i]
        b=a//500  
        c=(a%500)//100   
        d=((a%500)%100)//50  
        e=(((a%500)%100)%50)//10
        f=((((a%500)%100)%50)%10)//5
        g=(((((a%500)%100)%50)%10)%5)//1
        print(b+c+d+e+f+g)
        i=i+1

Submission status: Accepted

Solution code:
while True:
  coin = int(input())
  if coin == 0: break
  ans = 0
  oturi = 1000 - coin
  for i in [500,100,50,10,5,1]:
    ans += oturi // i
    oturi = oturi % i
  print(ans)

Submission status: Accepted

Solution code:
while True:
    coin=0
    n=int(input())
    if n==0:
        break
    else:
        money=1000-n
        if money//500>=1:
            coin1=int(money//500)
            money-=500*coin1
            coin+=coin1
        else:
            pass
        if money//100>=1:
            coin2=int(money//100)
            money-=100*coin2
            coin+=coin2
        else:
            pass
        if money//50>=1:
            coin3=int(money//50)
            money-=50*coin3
            coin+=coin3
        else:
            pass
        if money//10>=1:
            coin4=int(money//10)
            money-=10*coin4
            coin+=coin4
        else:
            pass
        if money//5>=1:
            coin5=int(money//5)
            money-=5*coin5
            coin+=coin5
        else:
            pass
        if money//1>=1:
            coin6=int(money//1)
            coin+=coin6
        else:
            pass
        
        print(coin)

Submission status: Accepted

Solution code:
#Volume5-0521
while True:
  nedan = input()
  if nedan == str(0):
    break
  o = str(1000 - int(nedan))
  m = int(0)
  if int(nedan) > 990:
    n = int(1)
  elif int(nedan) > 900:
    n = int(2)
  else:
    n = int(3)
  for a in range(n):
    if int(o[a]) < 5:
      m = m+int(o[a])
    else:
      m = m+int(o[a])-4
  print(m)

Submission status: Accepted

Solution code:
while True :
    x=int(input())
    if x==0:
        break
    else:
        a=(1000-x)//500
        b=(1000-x-500*a)//100
        c=(1000-x-500*a-100*b)//50
        d=(1000-x-500*a-100*b-50*c)//10
        e=(1000-x-500*a-100*b-50*c-10*d)//5
        f=1000-x-500*a-100*b-50*c-10*d-5*e
        print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
x=1000
while True:
    y=int(input())
    if y>0:
        a=(x-y)//500
        b=(x-y)%500//100
        c=(x-y)%100//50
        d=(x-y)%50//10
        e=(x-y)%10//5
        f=(x-y)%5
        print(a+b+c+d+e+f)
    else:
        break

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break
    a = 1000-n
    print(a//500 + a%500//100 + a%100//50 + a%50//10 + a%10//5 + a%5)

Submission status: Accepted

Solution code:
for i in range(5):
    a=int(input())
    A=1000-a
    x=A//500
    M=A%500
    y=M//100
    M=M%100
    z=M//50
    M=M%50
    w=M//10
    M=M%10
    u=M//5
    M=M%5
    
    if a==0: break

    print(x+y+z+w+u+M)

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    if x==0:
        break
    oturi=1000-x
    a=oturi//500
    b=oturi//100-a*5
    c=(oturi%100)//50
    d=(oturi%100)//10-c*5
    e=(oturi%10)//5
    f=(oturi%10)-e*5
    kazu=a+b+c+d+e+f
    print(kazu)

Submission status: Accepted

Solution code:
while True:
    p=int(input())      #while文のなかで定義
    if p==0:break       #p=pay
    a=0                 #aを定義しておく
    c=1000-p        #c=change
    for i in [500,100,50,10,5,1]:
        a+=c//i     #aにc//iを足す
        c=c%i
    print(a)

Submission status: Accepted

Solution code:
w=[500,100,50,10,5,1]
while True:
    x=1000-int(input())
    if x == 1000 : break
    y=0
    for i in w:
        y=y+x//i
        x=x%i
    print(y)

Submission status: Accepted

Solution code:
n=int(input())
while n>0:
    m=1000-n
    a=int(m/500)
    b=int(int(m%500)/100)
    c=int(int(m%100)/50)
    d=int(int(m%50)/10)
    e=int(int(m%10)/5)
    f=int(int(m%5)/1)
    print(a+b+c+d+e+f)
    n=int(input())

Submission status: Accepted

Solution code:
def main():
    def coin_count(n):
        cnt = 0
        a, b, c, d, e, f = 0, 0, 0, 0, 0, 0
        n = 1000 - n
        if n >= 500:
            a = n // 500
            n = n - 500 * a
        if n >= 100:
            b = n // 100
            n = n - 100 * b
        if n >= 50:
            c = n // 50
            n = n - 50 * c
        if n >= 10:
            d = n // 10
            n = n - 10 * d
        if n >= 5:
            e = n // 5
            n = n - 5 * e
        f = n
        ans = a + b + c + d + e + f
        print(ans)

    while True:
        n = int(input())
        if n == 0:
            break
        coin_count(n)  

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
price=int(input())
while price!=0:
    change=1000-price
    if change//500==1:
        fiveh=1
        change-=500
    else:
        fiveh=0
    if change//100>0:
        hundred=change//100
        change=change%100
    else:
        hundred=0
    if change//50>0:
        fifty=change//50
        change=change%50
    else:
        fifty=0
    if change//10:
        ten=change//10
        change=change%10
    else:
        ten=0
    if change//5:
        five=change//5
        change=change%5
    else:
        five=0
    one=change    
    print(fiveh+hundred+fifty+ten+five+one)  
    price=int(input())
else:
    pass

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n >= 1:
        x = 1000 - n
        a = x%500
        b = a%100
        c = b%50
        d = c%10
        e = d%5
        y = x//500 + a//100 + b//50 + c//10 + d//5 +e//1
        print(y)
    if n == 0:
        break

Submission status: Accepted

Solution code:
def oturi(now, kingaku):
    coin = now // kingaku
    if coin:
        now -= coin * kingaku
    return now, coin

while True:
    n = int(input())
    if n == 0:
        break
    now = 1000 - n
    coin = 0
    now, c = oturi(now, 500)
    coin += c
    now, c = oturi(now, 100)
    coin += c
    now, c = oturi(now, 50)
    coin += c
    now, c = oturi(now, 10)
    coin += c
    now, c = oturi(now, 5)
    coin += c
    now, c = oturi(now, 1)
    coin += c
    print(coin)

Submission status: Accepted

Solution code:
def keisan(a) :
    p=1000-a
    otsurifh=p//500
    otsurih=(p-otsurifh*500)//100
    otsurifj=(p-otsurifh*500-otsurih*100)//50
    otsurij=(p-otsurifh*500-otsurih*100-otsurifj*50)//10
    otsurig=(p-otsurifh*500-otsurih*100-otsurifj*50-otsurij*10)//5
    otsurii=(p-otsurifh*500-otsurih*100-otsurifj*50-otsurij*10-otsurig*5)
    return(otsurifh+otsurih+otsurifj+otsurij+otsurig+otsurii)

for i in range(5):
    c=int(input())
    if c==0 : break
    b=keisan(c)
    print(b)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    a=(1000-n)//500
    b=(1000-n-(500*a))//100
    c=(1000-n-(500*a)-(100*b))//50
    d=(1000-n-(500*a)-(100*b)-(50*c))//10
    e=(1000-n-(500*a)-(100*b)-(50*c)-(10*d))//5
    f=(1000-n-(500*a)-(100*b)-(50*c)-(10*d)-(5*e))//1
    print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
while True:
   x = int(input())
   if x == 0:
      break
   
   y = 1000 - x;
   a = y % 500
   b = a % 100
   c = b % 50
   d = c % 10
   e = d % 5
   z = y // 500 + a // 100 + b // 50 + c // 10 + d // 5 + e
   
   print(z)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n == 0:
        break
    a=1000-n
    B=a//500
    b=a%500
    C=b//100
    c=b%100
    D=c//50
    d=c%50
    E=d//10
    e=d%10
    F=e//5
    f=e%5
    G=f//1
    print(B+C+D+E+F+G)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    x=1000-n
    a=x//500
    b=(x%500)//100
    c=((x%500)%100)//50
    d=(((x%500)%100)%50)//10
    e=((((x%500)%100)%50)%10)//5
    f=((((x%500)%100)%50)%10)%5  
    if n==0:
        break
    else:
        print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
while True:
     m=int(input())
     p=1000-m
     y500=p//500
     x500=p%500
     y100=x500//100
     x100=x500%100
     y50=x100//50
     x50=x100%50
     y10=x50//10
     x10=x50%10
     y5=x10//5
     x5=x10%5
     if m==0:
          break
     print(y500+y100+y50+y10+y5+x5)

Submission status: Accepted

Solution code:
a = [500, 100, 50, 10, 5, 1]
while True:
	b = 1000-int(input())
	if b == 1000:
	        break
	c = 0
	for i in a:
		c += b // i
		b %= i 
	print(c)

Submission status: Accepted

Solution code:
i=1
while True:
    x=int(input())
    if x==0:
        break
    x=1000-x
    a=x//500
    b=(x%500)//100
    c=(x%100)//50
    d=(x%50)//10
    e=(x%10)//5
    f=x%5
    print(a+b+c+d+e+f)
    i+=1

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
        sum=0
        sum+=(1000-n)//500
        sum+=(1000-n)%500//100
        sum+=(1000-n)%500%100//50
        sum+=(1000-n)%500%100%50//10
        sum+=(1000-n)%500%100%50%10//5
        sum+=(1000-n)%500%100%50%10%5//1
        print(sum)

Submission status: Accepted

Solution code:
while True:
    a=1000-int(input())
    if a==1000:
        break
    c=[500,100,50,10,5,1]
    ans=0
    for i in c:
        ans+=a//i
        a=a%i
    print(ans)

Submission status: Accepted

Solution code:
a,b=1,0
while a>0:
    a=int(input())
    if a==0:
        break
    b=1000-a
    c=b//500
    d=b%500//100
    e=b%100//50
    f=b%50//10
    g=b%10//5
    h=b%5
    print(c+d+e+f+g+h)

Submission status: Accepted

Solution code:
a=[500,100,50,10,5,1]
while True:
  x=int(input())
  if x==0:
    break
  ans=0
  x=1000-x
  for i in a:
      ans += x//i
      x %= i
  print(ans)

Submission status: Accepted

Solution code:
while True:
	n = int(input())
	if n == 0:
		break
	m = 0
	c = 1000 - n
	while c != 0:
		if c >= 500:
			c = c - 500
			m = m + 1
		elif c >= 100:
			c = c - 100
			m = m + 1
		elif c >= 50:
			c = c - 50
			m = m + 1
		elif c >= 10:
			c = c - 10
			m = m + 1
		elif c >= 5:
			c = c - 5
			m = m + 1
		elif c >= 1:
			c = c - 1
			m = m + 1
	print(m)

Submission status: Accepted

Solution code:

while True:
    x=int(input())
    if x==0:
        break
    oturi=int(1000-x)
    
    a=oturi//500
    oturi=oturi%500
    b=oturi//100
    oturi=oturi%100
    c=oturi//50
    oturi=oturi%50
    d=oturi//10
    oturi=oturi%10
    e=oturi//5
    oturi=oturi%5
    f=oturi//1
    
    print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:

while True:
    a=int(input())
    if a==0:
        break
    x=0
    b=1000-a
    if b-500>=0:
        x=x+1
    else:
        pass
    c=b%500
    x=x+(c-c%100)//100
    d=c%100
    if d-50>=0:
        x=x+1
    else:
        pass
    e=d%50
    x=x+(e-e%10)//10
    f=e%10
    if f-5>=0:
        x=x+1
    else:
        pass
    g=f%5
    x=x+g
    print(x)

Submission status: Accepted

Solution code:
c = [500, 100, 50, 10, 5, 1]
while True:
    n = int(input())
    x = 1000 - n
    if x == 1000:
        break
    a = 0
    for i in c:
        a += x // i 
        x %= i 
    print(a)

Submission status: Accepted

Solution code:
a=int(input())
while a!=0:
    b=1000-a
    n=0
    if b>=500:
        n=n+1
        b=b-500
    if b>=100:
        n=n+b//100
        b=b%100
    if b>=50:
        n=n+1
        b=b-50
    if b>=10:
        n=n+b//10
        b=b%10
    if b>=5:
        n=n+1
        b=b-5
    n=n+b
    print(n)
    a=int(input())

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    chg = 1000 - n
    m = [500, 100, 50, 10, 5, 1]
    cnt = [0,0,0,0,0,0]
    for i in range(len(m)):
        cnt[i] = chg//m[i]
        chg -=cnt[i]*m[i]
    ans = 0
    for i in range(len(cnt)):
        ans += cnt[i]
    print(ans)

Submission status: Accepted

Solution code:
a = [500, 100, 50, 10, 5, 1]
while True:
  n = int(input())
  if n == 0:
    break
  n = 1000 - n
  ans = 0
  for i in a:
    ans += n // i
    n %= i
  print(ans)

Submission status: Accepted

Solution code:
x = int(input())
while x != 0:
    y = 1000 - x
    a = y//500
    b = (y-500*a)//100
    c = (y-(500*a+100*b))//50
    d = (y-(500*a+100*b+50*c))//10
    e = (y-(500*a+100*b+50*c+10*d))//5
    f = (y-(500*a+100*b+50*c+10*d+5*e))//1
    g = a+b+c+d+e+f
    print(g)
    x = int(input())

Submission status: Accepted

Solution code:

for i in range(5):
    x=int(input())
    a=1000-x
    if x!=0:
        b=0
        b+=(a//500)#500
        
        b+=(a%500)//100#100
        
        b+=((a%500)%100)//50#50
        
        b+=(((a%500)%100)%50)//10#10
        
        b+=((((a%500)%100)%50)%10)//5
        
        b+=((((a%500)%100)%50)%10)%5
    elif x==0:
        break
        
    print(b)

Submission status: Accepted

Solution code:
for i in range(5):
    s=0
    q=0
    n=int(input())
    if n==0:
        break
    n=1000-n
    if n>=500:
        n-=500
        s+=1
    if n>=100:
        q=n//100
        n-=100*q
        s+=q
    if n>=50:
        n-=50
        s+=1
    if n>=10:
        q=n//10
        n-=10*q
        s+=q
    if n>=5:
        n-=5
        s+=1
    if n>=1:
        q=n//1
        s+=q
    print(s)

Submission status: Accepted

Solution code:
i=0
while i<6:
    i+=1
    x=int(input())
    y=1000-x
    g=y//500
    h=(y-500*g)//100
    d=(y-500*g-100*h)//50
    z=(y-500*g-100*h-50*d)//10
    f=(y-500*g-100*h-50*d-10*z)//5
    i=y-500*g-100*h-50*d-10*z-5*f
    if x==0:
        break
    print(g+h+d+z+f+i)

Submission status: Accepted

Solution code:
a=0
while a<=1000:
    a=int(input())
    if a==0:
        break
    else:
        x=1000-a
        b=x//500#500coin
        c=x%500
        d=c//100#100coin
        e=c%100
        f=e//50
        g=e%50
        h=g//10#
        i=g%10
        j=i//5#
        k=i%5#
    print(b+d+f+h+j+k)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0 :
        break
    else:
        otsuri=1000-n
        a=otsuri//500
        b=otsuri%500//100
        c=otsuri%500%100//50
        d=otsuri%500%100%50//10
        e=otsuri%500%100%50%10//5
        f=otsuri%500%100%50%10%5
    print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
#0521
while True:
    n = int(input())
    if n == 0:
        break
    x = 1000 - n
    cnt = 0
    if x >= 500:
        cnt += 1
        x = x - 500
    if x > 100:
        cnt = cnt + x//100
        x = x - (100 * (x//100))
    if x >= 50:
        cnt = cnt + x//50
        x = x - (50 * (x//50))
    if x >= 10:
        cnt = cnt + x//10
        x = x - (10 * (x//10))
    if x >= 5:
        cnt = cnt + x//5
        x = x - (5 * (x//5))
    print(cnt + x)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=1000-n
        i=a%10
        if i>=5:
            i=1+i-5
        else:
            pass
        j=a//10
        j2=j%10
        if j2>=5:
            j2=1+j2-5
        else:
            pass
        h=a//100
        if h>=5:
            h=1+h-5
        else:
            pass
    print(i+j2+h)

Submission status: Accepted

Solution code:
i=0
while True:
    X=int(input())
    if X==0:
        break
    x=1000-X
    a=x//500
    b=x%500//100
    c=x%500%100//50
    d=x%500%100%50//10
    e=x%500%100%50%10//5
    f=x%500%100%50%10%5
    print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
n=int(input())
while n>0:
    m=1000-n
    a=int(m/500)
    b=int(int(m%500)/100)
    c=int(int(m%100)/50)
    d=int(int(m%50)/10)
    e=int(int(m%10)/5)
    f=int(int(m%5)/1)
    print(a+b+c+d+e+f)
    n=int(input())

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    y=1000
    if x==0:break
    else:
        z=y-x
        a=z//500
        b=(z-a*500)//100
        c=(z-a*500-b*100)//50
        d=(z-a*500-b*100-c*50)//10
        e=(z-a*500-b*100-c*50-d*10)//5
        f=(z-a*500-b*100-c*50-d*10-e*5)//1
        ans=a+b+c+d+e+f
        print(ans)

Submission status: Accepted

Solution code:
a = [500,100,50,10,5,1]
while True:
    x = int(input())
    if x == 0:
        break
    x = 1000-x
    b = 0
    for c in a:
        b += x//c
        x %= c
    print(b)

Submission status: Accepted

Solution code:
coin = [500,100,50,10,5,1]
while True:
 x = int(input())
 change = 1000-x
 if x == 0:break
 else:
     ans = 0
     for i in coin:
         ans += change // i
         change %= i
     print(ans)

Submission status: Accepted

Solution code:
try:
    while True:
        n=int(input())
        m=1000-n
        i=0
        if m==1000:
            break
        else:
            i+=m//500
            m=m%500
            i+=m//100
            m=m%100
            i+=m//50
            m=m%50
            i+=m//10
            m=m%10
            i+=m//5
            m=m%5
            i+=m
        print(i)
except EOFError:
    pass

Submission status: Accepted

Solution code:
while True :
    i = int(input())
    a = 0
    if i == 0 :
        break
    else :
        b = 1000 - i
        
        if b >= 500 :
            a += 1
            b -= 500
        
        while b >= 100 :
            a += 1
            b -= 100
        
        while b >= 50 :
            a += 1
            b -= 50
            
        while b >= 10 :
            a += 1
            b -= 10
            
        while b >= 5 :
            a += 1
            b -= 5
            
        a += b   
    
    print(a)

Submission status: Accepted

Solution code:
list=[]
for i in range(5):
   x=int(input())
   if x==0:
      break
   else:
      list.append(x)

for i in range(len(list)):
   y=list[i]
   a=1000-y
   b=a//500
   c=a%500
   d=c//100
   e=c%100
   f=e//50
   g=e%50
   h=g//10
   i=g%10
   j =i//5
   k=i%5
   sum=b+d+f+h+j+k
   print(str(sum))

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    y=1000-x
    a=0
    b=0
    a+=y//500
    b=y%500
    a+=b//100
    b=b%100
    a+=b//50
    b=b%50
    a+=b//10
    b=b%10
    a+=b//5
    b=b%5
    a+=b//1
    if x==0:
        break
    print(int(a))

Submission status: Accepted

Solution code:
while True:
    Y = int(input())
    if Y == 0:
        break
    X = 1000 - Y
    a = X // 500
    X = X - a * 500
    b = X // 100
    X = X - b * 100
    c = X // 50
    X = X - c * 50
    d = X // 10
    X = X - d * 10
    e = X // 5
    X = X - e * 5
    f = X // 1
    
    print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    oturi = 1000 - n
    li = [500,100,50,10,5,1]
    cnt = [0,0,0,0,0,0]
    for i in range(len(li)):
        cnt[i] = oturi//li[i]
        oturi -= cnt[i]*li[i]
    ans = 0
    for i in range(len(cnt)):
        ans += cnt[i]
    print(ans)

Submission status: Accepted

Solution code:
while True:
    s=int(input())
    if s==0:
        break
    a=1000-s
    b=a//500
    c=a%500
    d=c//100
    e=c%100
    f=e//50
    g=e%50
    h=g//10
    i=g%10
    j=i//5
    k=i%5
    print(b+d+f+h+j+k)

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    if x==0:
        break
    y=1000-x
    a=y//500
    b=(y-500*a)//100
    c=(y-500*a-100*b)//50
    d=(y-500*a-100*b-50*c)//10
    e=(y-500*a-100*b-50*c-10*d)//5
    f=(y-500*a-100*b-50*c-10*d-5*e)
    print(a+b+c+d+e+f)

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    if x==0:
        break
    a=1000-x
    b=a//500
    c=a%500
    d=c//100
    e=c%100
    f=e//50
    g=e%50
    h=g//10
    i=g%10
    j=i//5
    k=i%5
    print(b+d+f+h+j+k)

Submission status: Accepted

Solution code:
def co(n):
    a = int(1000-n)
    b = int(a//500)
    c = int((a%500)//100)
    d = int((a%100)//50)
    e = int((a%50)//10)
    f = int((a%10)//5)
    g = int((a%5)//1)
    sum = b+c+d+e+f+g
    print(sum)
for i in range(5):
    x = int(input())
    if x == 0:
        break
    co(x)

Submission status: Accepted

Solution code:
while True:
    a=int(input())
    if a==0:
        break
    b=(1000-a)//500
    c=(1000-a)%500//100
    d=(1000-a)%500%100//50
    e=(1000-a)%500%100%50//10
    f=(1000-a)%500%100%50%10//5
    g=(1000-a)%500%100%50%10%5
    print(b+c+d+e+f+g)

Submission status: Accepted

Solution code:
while True:
    a = int(input())
    if a == 0:
        break
    else:
        x = 1000-a
        b = int(x/500)
        c = int((x-500*b)/100)
        d = int((x-500*b-100*c)/50)
        e = int((x-500*b-100*c-50*d)/10)
        f = int((x-500*b-100*c-50*d-10*e)/5)
        g = int((x-500*b-100*c-50*d-10*e-5*f)/1)
        y = b+c+d+e+f+g
        print(y)

Submission status: Accepted

Solution code:
i = 1
while i <= 5:
    x = int(input())
    if x == 0:
        break
    y = 1000 - x
    c_1 = y//500
    c_2 = y%500//100
    c_3 = y%500%100//50
    c_4 = y%500%100%50//10
    c_5 = y%500%100%50%10//5
    c_6 = y%500%100%50%10%5//1
    print(c_1+c_2+c_3+c_4+c_5+c_6)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

while True:
    n = int(input())
    #print(n)
    if n==0:
        break
    n = 1000-n
    #print(n)
    m = n//500
    n = n%500
    #print(n,m)
    m += n//100
    n = n%100
    #print(n,m)
    m += n//50
    n = n%50
    #print(n,m)
    m += n//10
    n = n%10
    #print(n,m)
    m += n//5
    n = n%5
    #print(n,m)
    m += n
    #print(n,m)
    
    print(m)