Beispiel #1
0
	TEST(Median, calculate) {

		Median<float> med;

		ASSERT_THROW(med.get(), std::exception);

		med.add(1);
		ASSERT_EQ(1, med.get());

		med.add(2);
		ASSERT_EQ(1.5, med.get());

		med.add(3);
		ASSERT_EQ(2, med.get());

		med.add(99);
		ASSERT_EQ(2.5, med.get());


	}
int main() {
    std::ios_base::sync_with_stdio(false);
    int T;
    cin >> T;
    for (auto t = 0; t < T; ++t) {
        uint64_t a, b, c, n;
        cin >> a >> b >> c >> n;
        
        uint64_t f_sum = 1;
        Median<uint64_t> median;
        
        median.add(1);
        
        for (auto i = 2; i <= n; ++i) {
            auto f = (a*median.get() + b*i + c) % MOD;
            median.add(f);
            f_sum += f; 
        } 
        cout << f_sum << endl;
    }
}