Advertisement
Guest User

Untitled

a guest
Nov 6th, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. /haxxor
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. int n, s, b[100], max, last = 1, it = 0, d = 0;
  7. cout << "n = ", cin >> n;
  8. b[0] = 1;
  9. cout << "bancnota 1 = 1" << endl;
  10. for (int i = 1; i < n; i++)
  11. cout << "bancnota " << i + 1 << " = ", cin >> b[i];
  12. cout << "s = ", cin >> s;
  13. for (int i = 1; i < n; i++)
  14. if (s % b[i] == 0)
  15. d = b[i];
  16. if (d)
  17. cout << "Bancnota " << d << " de " << s / d << " ori." << endl;
  18. else
  19. {
  20. for (int i = 1; i < n; i++)
  21. if (last < b[i] && s >= b[i])
  22. last = b[i];
  23. while (s > 0)
  24. {
  25. max = 1;
  26. for (int i = 1; i < n; i++)
  27. if (max < b[i] && s >= b[i])
  28. max = b[i];
  29. if (last == max)
  30. it++;
  31. else
  32. {
  33. cout << "Bancnota " << last << " de " << it << " ori." << endl;
  34. last = max;
  35. it = 1;
  36. }
  37. s -= max;
  38. }
  39. cout << "Bancnota " << last << " de " << it << " ori." << endl;
  40. }
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement