forked from menault/2026_TD3_DEV51_Qualite_Algo
F8
This commit is contained in:
@@ -171,12 +171,21 @@ static const int PIECES[] = {1, 2, 5, 10, 20, 50, 100, 200};
|
||||
|
||||
long nb_facons_rendre(int somme, int nb_pieces)
|
||||
{
|
||||
if (somme == 0)
|
||||
return 1;
|
||||
if (somme < 0 || nb_pieces == 0)
|
||||
if (somme < 0)
|
||||
return 0;
|
||||
return nb_facons_rendre(somme - PIECES[nb_pieces - 1], nb_pieces) +
|
||||
nb_facons_rendre(somme, nb_pieces - 1);
|
||||
if (nb_pieces == 0)
|
||||
return somme == 0;
|
||||
|
||||
long dp[somme + 1];
|
||||
for (int s = 0; s <= somme; s++)
|
||||
dp[s] = 1; /* pièce de 1 : une seule façon */
|
||||
|
||||
for (int p = 1; p < nb_pieces; p++) {
|
||||
int c = PIECES[p];
|
||||
for (int s = c; s <= somme; s++)
|
||||
dp[s] += dp[s - c];
|
||||
}
|
||||
return dp[somme];
|
||||
}
|
||||
|
||||
static int categorie_debit(const Transaction *t)
|
||||
|
||||
Reference in New Issue
Block a user