Esempio n. 1
0
// Calcul du nombre de combinaison de n parmis p 
// en paramètre n > p > 0 
int combinaison(int n, int p) {
    if(p == 0 || p == n)
        return 1;
    if(0 < p && p < n)
        return combinaison(n-1, p-1) + combinaison(n-1, p);
    return 0;
}
Esempio n. 2
0
int main()
{
  Lists w {{1,2},{3,4,5},{6,7,8,9}};
  Lists result = combinaison(w);

  std::cout << std::endl << std::endl;
  for(auto& x : result)
  {
    for(auto& y : x)
      std::cout << y << ",";
    std::cout << std::endl;
  }
  std::cout << std::endl;

}
Esempio n. 3
0
File: main.c Progetto: NSenaud/IUT
int main( int argc, char *argv[] )
{
  /* *** Variables Declaration *** */
  
  int i = 0 ;
  int n=49, k=6 ;
  double proba = 0 ;


  /* *** Computing *** */

  proba = combinaison( k, n ) ;


  /* Result */

  printf("Probability: 1/%.0lf\n", proba) ;


  /* *** End of Program *** */

  return 0 ;
}
Esempio n. 4
0
        
        cache[m] = resultat;
        return resultat;
    }
}

ENREGISTRER_PROBLEME(161, "Triominoes")
{
	// A triomino is a shape consisting of three squares joined via the edges. There are two basic 
	// forms:
    //
    //              XXX     XX
    //                      X
    //
    // If all possible orientations are taken into account there are six:
    //
    //           X  X        X
    //      XXX  X  XX  XX  XX  XX
    //           X      X        X
    //
    // Any n by m grid for which nxm is divisible by 3 can be tiled with triominoes.
    // If we consider tilings that can be obtained by reflection or rotation from another tiling as 
    // different there are 41 ways a 2 by 9 grid can be tiled with triominoes:
    //
    // In how many ways can a 9 by 12 grid be tiled in this way by triominoes?
    matrice m (9, std::vector<bool>(12, true));
    std::map<matrice, nombre> cache;
    nombre resultat = combinaison(cache, m);
    return std::to_string(resultat);
}
Esempio n. 5
0
// Initialise une matrice C de taille N en paramètre avec les valeau d'un
// triangle de pascal on rempli les cases vides à 0
void pascal(int C[N][N]) {
    int i, j;
    for(i = 0; i < N; ++i)
        for(j = 0; j < N; ++j)
            C[i][j] = combinaison(i, j);
}