Update include.hh
Signed-off-by: subcrip <contact@subc.rip>
This commit is contained in:
parent
5d28967e3f
commit
d20bb2ed65
18
include.hh
18
include.hh
|
@ -24,6 +24,7 @@ using ull = uint64_t;
|
||||||
#else
|
#else
|
||||||
using ll = long long;
|
using ll = long long;
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
|
using ld = long double;
|
||||||
#endif
|
#endif
|
||||||
using int128 = __int128_t;
|
using int128 = __int128_t;
|
||||||
using uint128 = __uint128_t;
|
using uint128 = __uint128_t;
|
||||||
|
@ -236,6 +237,7 @@ ll inverse(ll a, ll b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<tuple<int, int, ll>> decompose(ll x) {
|
vector<tuple<int, int, ll>> decompose(ll x) {
|
||||||
|
// return (factor, count, factor ** count)
|
||||||
vector<tuple<int, int, ll>> res;
|
vector<tuple<int, int, ll>> res;
|
||||||
for (int i = 2; i * i <= x; i++) {
|
for (int i = 2; i * i <= x; i++) {
|
||||||
if (x % i == 0) {
|
if (x % i == 0) {
|
||||||
|
@ -251,6 +253,22 @@ vector<tuple<int, int, ll>> decompose(ll x) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<pii> decompose_prime(int N) {
|
||||||
|
// return (factor, count)
|
||||||
|
vector<pii> result;
|
||||||
|
for (int i = 2; i * i <= N; i++) {
|
||||||
|
if (N % i == 0) {
|
||||||
|
int cnt = 0;
|
||||||
|
while (N % i == 0) N /= i, ++cnt;
|
||||||
|
result.emplace_back(i, cnt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (N != 1) {
|
||||||
|
result.emplace_back(N, 1);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* string algorithms */
|
/* string algorithms */
|
||||||
vector<int> calc_next(string t) { // pi function of t
|
vector<int> calc_next(string t) { // pi function of t
|
||||||
int n = (int)t.length();
|
int n = (int)t.length();
|
||||||
|
|
Loading…
Reference in New Issue