z=c((u<-c(5,2,1))*1e4,u*1e3,u*1e2,u*10,u) b=function(x){ o=NULL while (x>0){ b=x%/%z a=b[b>0][1] c=z[which(b>0)][1] x=x-a*c o=c(o,rep(c,a))} cat(o,sep="+");cat("\n")} for(i in scan("stdin"))b(i)