これで駄目なら…
#include <stdio.h>
main(){int(*p)()=putchar,n;struct{int c,n;}r[]={77,1000,68,500,67,100,76,50,88,
10,86,5,73,1,0,0},*t=r;for(scanf("%d",&n);n<4000&n>0;)n>=t->n?p(t->c),n-=t->n:t
->n==t[1].n*5&n>=t->n-t[1].n?p(t[1].c),p(t->c),n-=t->n+t[1].n:t++;}