#include #include #ifndef min #define min(a,b) (((a)<(b))?(a):(b)) #endif #define MAX 501 /* max num of terms, not of lines */ #define NUM ((MAX+1)*(MAX+2)>>1) #define Table(start,length) cost_table[num[start]+length] int count,term[MAX]; int cost_table[NUM]; int num[MAX],dec_num[MAX]; void init(char *filename) { FILE *fp; int buf,h; fp=fopen(filename,"r"); while(EOF!=fscanf(fp,"%d %d",&term[count],&buf)){ count++; } term[count]=buf; count++; fclose(fp); for(h=1;h