Artifact Content
Not logged in

Artifact 07008cbdf3a5db57053babbb7960e945fa782399


#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;

class SequenceSums {
public:
	vector <int> sequence(int N, int LL) 
	{
		for(int L=LL; L<=100; ++L)
		{
			int Z = N - L*(L-1)/2;
			if( Z % L )
				continue;
			int a = Z / L;
			if( a < 0 )
				continue;

			vector<int> ans;
			for(int x=a; x<a+L; ++x)
				ans.push_back(x);
			return ans;
		}
		return vector<int>();
	}
};

// 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> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
int verify_case(const vector <int> &Expected, const vector <int> &Received) { if (Expected == Received) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; cerr << "\tExpected: " << print_array(Expected) << endl; cerr << "\tReceived: " << print_array(Received) << endl; } return 0;}

template<int N> struct Case_ { Case_(){start_time=clock();} };
char Test_(...);
int Test_(Case_<0>) {
	int N = 18; 
	int L = 2; 
	int RetVal_[] = {5, 6, 7 };
	  vector <int> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_)); 
	return verify_case(RetVal, SequenceSums().sequence(N, L)); }
int Test_(Case_<1>) {
	int N = 18; 
	int L = 4; 
	int RetVal_[] = {3, 4, 5, 6 };
	  vector <int> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_)); 
	return verify_case(RetVal, SequenceSums().sequence(N, L)); }
int Test_(Case_<2>) {
	int N = 18; 
	int L = 5; 
	vector <int> RetVal; 
	return verify_case(RetVal, SequenceSums().sequence(N, L)); }
int Test_(Case_<3>) {
	int N = 45; 
	int L = 10; 
	int RetVal_[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
	  vector <int> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_)); 
	return verify_case(RetVal, SequenceSums().sequence(N, L)); }
int Test_(Case_<4>) {
	int N = 1000000000; 
	int L = 2; 
	int RetVal_[] = {199999998, 199999999, 200000000, 200000001, 200000002 };
	  vector <int> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_)); 
	return verify_case(RetVal, SequenceSums().sequence(N, L)); }

template<int N> void Run_() { cerr << "Test Case #" << N << "..." << flush; Test_(Case_<N>()); Run_<sizeof(Test_(Case_<N+1>()))==1 ? -1 : N+1>(); }
template<>      void Run_<-1>() {}
int main() { Run_<0>(); }
// END CUT HERE