Luzhiled's Library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub ei1333/library

:warning: Sum of Arithmetic Sequence(等差数列の和)
(math/combinatorics/sum-of-arithmetic-sequence.hpp)

Code

/**
 * @brief Sum of Arithmetic Sequence(等差数列の和)
 */
template< typename Mint >
Mint sum_of_arithmetic_sequence(const Mint &a, const Mint &d, const Mint &n) {
  return n * (2 * a + (n - 1) * d) / 2;
}
#line 1 "math/combinatorics/sum-of-arithmetic-sequence.hpp"
/**
 * @brief Sum of Arithmetic Sequence(等差数列の和)
 */
template< typename Mint >
Mint sum_of_arithmetic_sequence(const Mint &a, const Mint &d, const Mint &n) {
  return n * (2 * a + (n - 1) * d) / 2;
}
Back to top page