This documentation is automatically generated by online-judge-tools/verification-helper
#include "lib/math/enumerate_quotients.hpp"
正整数 $N$ について、$1 \leq x \leq N$ における $\lfloor N / x \rfloor$ (商)としてあり得る値を列挙します。
また、その商となる $x$ の区間も同時に取得します。
#pragma once
/**
* @brief Enumerate Quotients (商列挙)
* @docs docs/math/enumerate_quotients.md
*/
template <typename T>
vector<tuple<T, T, T>> enumerate_quotients(const T &n){
vector<tuple<T, T, T>> res;
for(T l = 1; l <= n;){
const T quotient = n / l;
const T r = n / quotient + 1;
// [l, r)
res.emplace_back(l, r, quotient);
l = r;
}
return res;
}
#line 2 "lib/math/enumerate_quotients.hpp"
/**
* @brief Enumerate Quotients (商列挙)
* @docs docs/math/enumerate_quotients.md
*/
template <typename T>
vector<tuple<T, T, T>> enumerate_quotients(const T &n){
vector<tuple<T, T, T>> res;
for(T l = 1; l <= n;){
const T quotient = n / l;
const T r = n / quotient + 1;
// [l, r)
res.emplace_back(l, r, quotient);
l = r;
}
return res;
}