cpplibforCP

Revision en3, by izlyforever, 2021-06-19 17:15:24

Hello, codeforces

I write a personal C++ template for Competitive Programming Algorithms. It contains many common algorithms, especially mathematical ones.

I know that the more you use it, the more reliable it is. Almost all template are tested in a Chinese OJ: LuoGu. However, no one can ensure that no bugs in their code.

Thanks in advance if you find some bugs or give other testes.

As we know, programmers hate two things:

  • writing documents
  • others who don't writing documents

Here is Document and Source Code

As an example, you can solve $$$n! \mod p$$$ in SPOJ where $$$0 < n, p < 10^{11}$$$, use following simple code.

#include <bits/stdc++.h>
#define clog(x) std::clog << (#x) << " is " << (x) << '\n';
using LL = long long;
#include "../cpplib/math.hpp"

// https://www.spoj.com/problems/FACTMODP/en/
int main() {
	// freopen("in", "r", stdin);
	std::cin.tie(nullptr)->sync_with_stdio(false);
	int cas = 1;
	std::cin >> cas;
	while (cas--) {
		LL n, p;
		std::cin >> n >> p;
		std::cout << factorial(n, p) << '\n';
	}
	return 0;
}
Tags #math, #c++ template

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en9 English MikeMirzayanov 2022-09-06 12:04:02 0 (published)
en8 English izlyforever 2021-09-12 20:56:45 4
en7 English izlyforever 2021-09-12 20:56:15 101
en6 English izlyforever 2021-06-23 15:46:42 0 (published)
en5 English izlyforever 2021-06-23 15:44:46 180 (saved to drafts)
en4 English izlyforever 2021-06-19 17:21:43 204 (published)
en3 English izlyforever 2021-06-19 17:15:24 604
en2 English izlyforever 2021-06-19 17:09:46 310
en1 English izlyforever 2021-06-19 13:59:31 696 Initial revision (saved to drafts)