cp-library

競技プログラミング用 C++ ライブラリ

View the Project on GitHub qandori/cp-library

:heavy_check_mark: test/binomial_prefix_sum_online_light.test.cpp

test/binomial_prefix_sum_online_light.test.cpp · GitHub で見る

検証問題

依存ライブラリ

コード

#define PROBLEM "https://yukicoder.me/problems/no/2206"
#include "math/binomial_prefix_sum_light.hpp"
#include "components/fast_io.hpp"

int main() {
	FastInput input;
	FastOutput output;
	int q = 0, limit = 0;
	input.read(q);
	std::vector<std::pair<int, int>> queries(q);
	for (auto& [n, k] : queries) input.read(n), input.read(k), --n, limit = std::max(limit, n);
	light_combinatorics::BinomialPrefixSum<> prefix(limit);
	for (auto [n, k] : queries) {
		auto total = prefix.query(n, std::int64_t(n) + 1);
		output.println((prefix.query(n, k) * (total + total - mint(1))).val());
	}
}
Back to top page