library

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

View the Project on GitHub sash2104/library

:warning: 約数列挙
(math/divisor.hpp)

Required by

Code

// @title 約数列挙
#include <algorithm>
#include <vector>

using ll = long long;

std::vector<ll> divisor(ll n) { 
  std::vector<ll> ret;
  for (ll i = 1; (ll)i*i <= n; ++i) { 
    if (n % i == 0) {
      ret.push_back(i);
      if (i*i != n) { ret.push_back(n/i); }
    }
  }
  std::sort(ret.begin(), ret.end());
  return ret;
};
#line 1 "math/divisor.hpp"
// @title 約数列挙
#include <algorithm>
#include <vector>

using ll = long long;

std::vector<ll> divisor(ll n) { 
  std::vector<ll> ret;
  for (ll i = 1; (ll)i*i <= n; ++i) { 
    if (n % i == 0) {
      ret.push_back(i);
      if (i*i != n) { ret.push_back(n/i); }
    }
  }
  std::sort(ret.begin(), ret.end());
  return ret;
};
Back to top page