#include <iostream>
using namespace std;
#include <math.h>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main() {
int n=4;
int G[] = { 2135,1862,2639,2581 };
int sumG = 0;
int sum = 0;
for (int i = 0; i < n; i++) {
sumG = sumG + G[i];
}
int a[] = { 100,50,10,5,1 };
int m = sizeof(a) / sizeof(a[0]);
int b[5];
for (int i = 0; i < m; i++) {
b[i] = m;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
while (G[i] >= a[j]) {
G[i] = G[i] - a[j];
b[j]++;
}
}
}
for (int i = 0; i < m; i++) {
cout << "需要" << b[i] << "张面值为" << a[i] << "元的纸币" << endl;
sum = sum + b[i] * a[i];
}
if (sumG == sum) {
printf("该算法正确!");
}
}