cpp/math/factorize.cpp
- View this file on GitHub
- Last update: 2021-10-17 04:23:34+00:00
Required by
Code
//B
template<typename T>
pair<int,map<T,int>> Factorize(T n){
map<T,int> a;
int b = 0;
for(T i = 2; n >= i*i; i++){
while(!(n%i)){
n/=i;
a[i]++;
b++;
}
}
if(n != 1)a[n]++,b++;
return make_pair(b,a);
}
//E
#line 1 "cpp/math/factorize.cpp"
//B
template<typename T>
pair<int,map<T,int>> Factorize(T n){
map<T,int> a;
int b = 0;
for(T i = 2; n >= i*i; i++){
while(!(n%i)){
n/=i;
a[i]++;
b++;
}
}
if(n != 1)a[n]++,b++;
return make_pair(b,a);
}
//E