Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. bool make(long int n,long int b,long int a, vector<long int>& v) {
  8. if (a==b) {
  9. if (n%a==0) {
  10. for (long int i=0; i<n/a; ++i) {
  11. v.push_back(a);
  12. }
  13. return true;
  14. }
  15. return false;
  16. }
  17. //cout << "trying for " << n << endl;
  18. while(n >= b) {
  19. //cout << "- " << b << endl;
  20. v.push_back(b);
  21. n-=b;
  22. }
  23. if (n>=a) {
  24. v.push_back(n);
  25. return true;
  26. }
  27. if (n<a) {
  28. v.pop_back();
  29. return make(n+b, b-1, a, v);
  30. }
  31. }
  32.  
  33. int main()
  34. {
  35. long int n, a, b;
  36. cin >> n >> a >> b;
  37. vector<long int> v;
  38. //make(59, 10, 8, v, c); //PROSOXH DEXETAI B, A
  39. if (make(n,b,a,v)) {
  40. cout << "YES\n";
  41. sort(v.begin(), v.end());
  42. for (auto i:v) {
  43. cout << i << " ";
  44. }
  45. }
  46. else {
  47. cout << "NO\n";
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement