9 #define _CRT_SECURE_NO_WARNINGS
46 return 2 * coins2 + 7 * coins7 + 8 * coins8 + 19 * coins19;
56 return (coins2 == mon.
coins2) && (coins7 == mon.
coins7) &&
84 return s.money() == N;
88 return s.money() <= N;
90 virtual void generateChildren(
96 sols = vector<CCoinDistribution>(4,
s);
106 return static_cast<double>(N -
s.money()) / 19.0;
110 return s.coins2 +
s.coins7 +
s.coins8 +
s.coins19;
117 int main(
int argc,
char** argv)
123 "Input an integer number to solve a problem, or \"e\" to end.\n");
128 printf(
"Please, input a positive integer.\n\n");
131 if (strlen(text) == 1 && (text[0] ==
'e' || text[0] ==
'E'))
break;
132 int val = atoi(text);
135 printf(
"Please, input a positive integer.\n\n");
142 switch (prob.getOptimalSolution(solIni, solFin, HUGE_VAL, 15))
146 "No solution has been found. Either the number is too "
147 "small, or the time elapsed has exceeded 15 seconds.\n\n");
150 printf(
"An optimal solution has been found:\n");
152 "\t%u coins of 2 piastres.\n\t%u coins of 7 "
153 "piastres.\n\t%u coins of 8 piastres.\n\t%u coins of 19 "
160 "A solution has been found, although it may not be "
163 "\t%u coins of 2 piastres.\n\t%u coins of 7 "
164 "piastres.\n\t%u coins of 8 piastres.\n\t%u coins of 19 "