Artifact 8a1cb626f49403d657ed94c4da0461e5bc336a2a
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
#ifdef __GNUC__
#include <ext/hash_map>
#define unordered_map __gnu_cxx::hash_map
#else
#include <unordered_map>
#endif
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class P8XCoinChangeAnother { public:
vector<long long> solve(int N, long long coins_sum, long long coins_count)
{
vector<LL> result;
for(int i=0; i<N; ++i) {
LL tick = i==N-1 ? coins_sum>>i : ((1LL<<i)&coins_sum ? 1 : 0);
result.push_back( tick );
coins_count -= tick;
}
if( coins_count < 0 )
return vector<LL>();
for(int i=N-1; i>0; --i) {
if( coins_count == 0 )
return result;
else {
LL& me = result[i];
LL dec = min(me, coins_count);
me -= dec;
result[i-1] += dec*2;
coins_count -= dec;
}
}
return coins_count == 0 ? result : vector<LL>();
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const vector<long long>& Expected, const vector<long long>& Received) {
bool ok = (Expected == Received);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: " << Expected << endl << "\tx: " << Received << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, P8XCoinChangeAnother().solve(N, coins_sum, coins_count));}
int main(){
CASE(0)
int N = 2;
long long coins_sum = 4LL;
long long coins_count = 3LL;
long long __[] = {2, 1 };
vector<long long> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(1)
int N = 3;
long long coins_sum = 6LL;
long long coins_count = 3LL;
long long __[] = {0, 3, 0 };
vector<long long> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(2)
int N = 2;
long long coins_sum = 8LL;
long long coins_count = 1LL;
vector<long long> _;
END
CASE(3)
int N = 1;
long long coins_sum = 10000000000LL;
long long coins_count = 10000000000LL;
long long __[] = {10000000000 };
vector<long long> _(__, __+sizeof(__)/sizeof(*__));
END
/*
CASE(4)
int N = ;
long long coins_sum = LL;
long long coins_count = LL;
long long __[] = ;
vector<long long> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(5)
int N = ;
long long coins_sum = LL;
long long coins_count = LL;
long long __[] = ;
vector<long long> _(__, __+sizeof(__)/sizeof(*__));
END
*/
}
// END CUT HERE