library

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

View the Project on GitHub gyouzasushi/library

:heavy_check_mark: Quotient Blocks
(math/quotient_blocks.hpp)

概要

使い方

制約

計算量

Verified with

Code

#pragma once
#include <cassert>
#include <vector>
struct quotient_block {
    long long l, r, q;
};
std::vector<quotient_block> quotient_blocks(long long n) {
    assert(n >= 0);
    std::vector<quotient_block> ret;
    for (long long l = 1; l <= n;) {
        long long q = n / l, r = n / q + 1;
        ret.push_back({l, r, q});
        l = r;
    }
    return ret;
}
#line 2 "math/quotient_blocks.hpp"
#include <cassert>
#include <vector>
struct quotient_block {
    long long l, r, q;
};
std::vector<quotient_block> quotient_blocks(long long n) {
    assert(n >= 0);
    std::vector<quotient_block> ret;
    for (long long l = 1; l <= n;) {
        long long q = n / l, r = n / q + 1;
        ret.push_back({l, r, q});
        l = r;
    }
    return ret;
}
Back to top page