-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdollars.cpp
49 lines (40 loc) · 947 Bytes
/
dollars.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
ifstream fin("dollars.in");
ofstream fout("dollars.out");
int main()
{
vector<long long> dp(6001, 0);
vector<int> dollars = {2000, 1000, 400, 200, 100, 40, 20, 10, 4, 2, 1};
dp[0] = 1;
for (int c = 10; c >= 0; --c)
{
for (int i = dollars[c]; i <= 6000; ++i)
{
dp[i] += dp[i - dollars[c]];
}
}
while (true)
{
double in = 0.00;
fin >> in;
if (in == 0.00)
{
break;
}
double temp0 = in + 0.005;
temp0 *= 100;
int temp1 = temp0;
fout << fixed << setprecision(2) << setw(6) << in << setw(17) << dp[temp1 / 5] << '\n';
}
return 0;
}