Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- bool make(long int n,long int b,long int a, vector<long int>& v) {
- if (a==b) {
- if (n%a==0) {
- for (long int i=0; i<n/a; ++i) {
- v.push_back(a);
- }
- return true;
- }
- return false;
- }
- //cout << "trying for " << n << endl;
- while(n >= b) {
- //cout << "- " << b << endl;
- v.push_back(b);
- n-=b;
- }
- if (n>=a) {
- v.push_back(n);
- return true;
- }
- if (n<a) {
- v.pop_back();
- return make(n+b, b-1, a, v);
- }
- }
- int main()
- {
- long int n, a, b;
- cin >> n >> a >> b;
- vector<long int> v;
- //make(59, 10, 8, v, c); //PROSOXH DEXETAI B, A
- if (make(n,b,a,v)) {
- cout << "YES\n";
- sort(v.begin(), v.end());
- for (auto i:v) {
- cout << i << " ";
- }
- }
- else {
- cout << "NO\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement