This documentation is automatically generated by competitive-verifier/competitive-verifier
#include "nt/quotients.hpp"
#pragma once
#include "prelude.hpp"
#include "arith/sqrt.hpp"
// { m//d for d in [1..m] }
template <class T>
vector<T> quotients(T m) {
int l = floor_sqrt(m), k = m / (l + 1);
vector<T> qs(l + k);
rep(i, l) qs[i] = i + 1;
rep(i, k) qs[i + l] = m / (k - i);
return qs;
}
#line 2 "prelude.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vc = vector<char>;
#define rep2(i, m, n) for (auto i = (m); i < (n); i++)
#define rep(i, n) rep2(i, 0, n)
#define repr2(i, m, n) for (auto i = (n); i-- > (m);)
#define repr(i, n) repr2(i, 0, n)
#define all(x) begin(x), end(x)
auto ndvec(int n, auto e) { return vector(n, e); }
auto ndvec(int n, auto ...e) { return vector(n, ndvec(e...)); }
auto comp_key(auto&& f) { return [&](auto&& a, auto&& b) { return f(a) < f(b); }; }
auto& max(const auto& a, const auto& b) { return a < b ? b : a; }
auto& min(const auto& a, const auto& b) { return b < a ? b : a; }
#if __cpp_lib_ranges
namespace R = std::ranges;
namespace V = std::views;
#endif
#line 3 "arith/sqrt.hpp"
template <class T, enable_if_t<sizeof(T) <= 8>* = nullptr>
constexpr T floor_sqrt(T x) {
if (x == 0) return 0;
T s = round(sqrt(x));
return (s + x / s) / 2;
}
template <class T, enable_if_t<sizeof(T) <= 8>* = nullptr>
constexpr T ceil_sqrt(T x) {
return x == 0 ? 0 : floor_sqrt(x - 1) + 1;
}
#line 4 "nt/quotients.hpp"
// { m//d for d in [1..m] }
template <class T>
vector<T> quotients(T m) {
int l = floor_sqrt(m), k = m / (l + 1);
vector<T> qs(l + k);
rep(i, l) qs[i] = i + 1;
rep(i, k) qs[i + l] = m / (k - i);
return qs;
}