Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /haxxor
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, s, b[100], max, last = 1, it = 0, d = 0;
- cout << "n = ", cin >> n;
- b[0] = 1;
- cout << "bancnota 1 = 1" << endl;
- for (int i = 1; i < n; i++)
- cout << "bancnota " << i + 1 << " = ", cin >> b[i];
- cout << "s = ", cin >> s;
- for (int i = 1; i < n; i++)
- if (s % b[i] == 0)
- d = b[i];
- if (d)
- cout << "Bancnota " << d << " de " << s / d << " ori." << endl;
- else
- {
- for (int i = 1; i < n; i++)
- if (last < b[i] && s >= b[i])
- last = b[i];
- while (s > 0)
- {
- max = 1;
- for (int i = 1; i < n; i++)
- if (max < b[i] && s >= b[i])
- max = b[i];
- if (last == max)
- it++;
- else
- {
- cout << "Bancnota " << last << " de " << it << " ori." << endl;
- last = max;
- it = 1;
- }
- s -= max;
- }
- cout << "Bancnota " << last << " de " << it << " ori." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement