1-04-23から1日間の記事一覧

Maximize (L1+L2+..)!/L1!L2!..

Under restriction of Li>1 and L1+2L2+3L3..=N #include <stdio.h> #include <stdlib.h> #include <math.h> #define NMAX 300 int N; double lfactab[NMAX]; // log(n!) double logfac(int n) { double res=0; int i; for(i=2;i<=n;i++)res += log(i*1.0); return res; } // tabulize l</math.h></stdlib.h></stdio.h>…