This documentation is automatically generated by competitive-verifier/competitive-verifier
#include "tools/greater_equal_moebius.hpp"
(1)
template <typename InputIterator, typename OutputIterator>
void greater_equal_moebius(InputIterator begin, InputIterator end, OutputIterator result);
(2)
template <typename RandomAccessIterator>
void greater_equal_moebius(RandomAccessIterator begin, RandomAccessIterator end);
begin
and end
, it stores the sequence $(a_0, a_1, \ldots, a_{N - 1})$ that satisfies the following relational equation to result
.begin
and end
, it stores the sequence $(a_0, a_1, \ldots, a_{N - 1})$ that satisfies the following relational equation to begin
.The following relationship holds between $a$ and $b$.
\[\begin{align*} b_i &= \sum_{i \leq j < N} a_j \end{align*}\]result
in (1) can be the same as begin
, but it would be better to use (2) in that case.#ifndef TOOLS_GREATER_EQUAL_MOEBIUS_HPP
#define TOOLS_GREATER_EQUAL_MOEBIUS_HPP
#include <iterator>
#include <vector>
#include <algorithm>
namespace tools {
template <typename RandomAccessIterator>
void greater_equal_moebius(const RandomAccessIterator begin, const RandomAccessIterator end) {
const int N = end - begin;
for (int i = 0; i + 1 < N; ++i) {
begin[i] -= begin[i + 1];
}
}
template <typename InputIterator, typename OutputIterator>
void greater_equal_moebius(const InputIterator begin, const InputIterator end, const OutputIterator result) {
using T = typename ::std::iterator_traits<InputIterator>::value_type;
::std::vector<T> b(begin, end);
::tools::greater_equal_moebius(b.begin(), b.end());
::std::move(b.begin(), b.end(), result);
}
}
#endif
#line 1 "tools/greater_equal_moebius.hpp"
#include <iterator>
#include <vector>
#include <algorithm>
namespace tools {
template <typename RandomAccessIterator>
void greater_equal_moebius(const RandomAccessIterator begin, const RandomAccessIterator end) {
const int N = end - begin;
for (int i = 0; i + 1 < N; ++i) {
begin[i] -= begin[i + 1];
}
}
template <typename InputIterator, typename OutputIterator>
void greater_equal_moebius(const InputIterator begin, const InputIterator end, const OutputIterator result) {
using T = typename ::std::iterator_traits<InputIterator>::value_type;
::std::vector<T> b(begin, end);
::tools::greater_equal_moebius(b.begin(), b.end());
::std::move(b.begin(), b.end(), result);
}
}