Artifact Content
Not logged in

Artifact b74c3219548cc7103640d7554a123ea0410831c1


#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>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

static const LL MODVAL = 1000000007;


LL ADD(LL x, LL y) { return (x+y)%MODVAL; }
LL SUB(LL x, LL y) { return (x-y+MODVAL)%MODVAL; }
LL MUL(LL x, LL y) { return (x*y)%MODVAL; }
LL POW(LL x, LL e) {
	LL v = 1;
	for(;e;x=MUL(x,x),e>>=1)
		if(e&1)
			v = MUL(v, x);
	return v;
}
LL DIV(LL x, LL y) { return MUL(x, POW(y, MODVAL-2)); }

LL C(LL n, LL k) {
	LL v = 1;
	for(LL i=1; i<=k; ++i)
		v = DIV(MUL(v, n-i+1), i);
	return v;
}

class SuperSum { public:
	int calculate(int k, int n) 
	{
		return C(n+k, k+1);
	}
};

// 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 int& Expected, const int& 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(_, SuperSum().calculate(k, n));}
int main(){

CASE(0)
	int k = 1; 
	int n = 3; 
	int _ = 6; 
END
CASE(1)
	int k = 2; 
	int n = 3; 
	int _ = 10; 
END
CASE(2)
	int k = 4; 
	int n = 10; 
	int _ = 2002; 
END
CASE(3)
	int k = 10; 
	int n = 35; 
	int _ = 150595840; 
END
CASE(4)
	int k = 1; 
	int n = 1; 
	int _ = 1; 
END
CASE(5)
	int k = 50; 
	int n = 1000000000; 
	int _ = -1; 
END
CASE(6)
	int k = 50; 
	int n = 900000000; 
	int _ = -1; 
END

}
// END CUT HERE