还是整数分解问题,注意n本身也是约数
#include <iostream>
int main(){
printf("2430");
return 0;
}
#include <iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll n = 2021041820210418LL;
const ll maxn = 44955998;
ll p[maxn] = {1};
int main(){
ll sqr = (ll) sqrt(n), count = 0, num = 1;//126432 44955998
for(int i = 2; i <= sqr; i++){
if(n % i == 0){
p[num++] = i;
if(i * i != n) p[num++] = n / i;
}
}
p[num] = n;
for(int i = 0; i <= num; i++){
for(int j = 0; j <= num; j++){
for(int k = 0; k <= num; k++){
if(p[i]*p[j]*p[k] == n) {
count++;
printf("%lld %lld %lld\n", p[i], p[j], p[k]);
}
}
}
}
printf("%lld", count);
return 0;
}