Saturday, June 6, 2015

UVa 147 - Dollars

// UVa 147 - Dollars

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

#define datatype unsigned long long int

int coin[11] = { 2000, 1000, 400, 200, 100, 40, 20, 10, 4, 2, 1 };

datatype T[6001];

int main() {

	double nf;
	cin >> nf;
	while (nf != 0) {
		int n = (int) (nf * 20);
		memset(T, 0, sizeof(T));
		T[0] = 1;
		for (int i = 0; i < 11; i++) {
			for (int j = coin[i]; j <= n; j++) {
				if (T[j - coin[i]] != 0)
					T[j] += T[j - coin[i]];
			}
		}
		printf("%6.2f%17llu\n", nf, T[n]);

		cin >> nf;
	}

	return 0;
}

No comments:

Post a Comment