#include <iostream>
using namespace std;
int main()
{
int val[7] = { 1, 2, 5, 10, 20, 50, 100};
int max[7] = {200,100, 40, 20, 10, 4, 2};
int a,b,c,d,e,f,g;
int cont = 0;
for(a = 0 ; a<=max[0] ; a++)
for(b = 0 ; b<=max[1] ; b++)
for(c = 0 ; c<=max[2] ; c++)
for(d = 0 ; d<=max[3] ; d++)
for(e = 0 ; e<=max[4] ; e++)
for(f = 0 ; f<=max[5] ; f++)
for(g = 0 ; g<=max[6] ; g++)
if(a*val[0]+b*val[1]+c*val[2]+d*val[3]+e*val[4]+f*val[5]+g*val[6] == 200)
cont++;
cont++; // mas la que se puede formar con 1 sola moneda de 2 libras :D
cout << cont << endl;
return 0;
}
viernes, 10 de febrero de 2012
Project Euler 31
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario