Files
lanqiao/12lanqiao/test4.cpp
2025-04-10 10:21:31 +08:00

33 lines
876 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// lanqiao 1463 货物摆放
#include<bits/stdc++.h>
using namespace std;
#define int long long
/*
搜索解法由于n过大严重超时无法跑出结果
枚举解法:由于只有三个位置,所以直接枚举三个位置上的数字
*/
signed main(){
int n = 2021041820210418;
vector<int> p; // 找到n的所有因子并存储起来进而针对枚举范围进行优化
for(int i = 1; i <= sqrt(n); i++){
if(n % i == 0){
p.push_back(i);
if(i != n/i) p.push_back(n/i);
}
}
int ans = 0;
// 枚举因子,计算方案数量
for(int i = 0; i < p.size(); i++){
for(int j = 0; j < p.size(); j++){
for(int k = 0; k < p.size(); k++){
if(p[i] * p[j] * p[k] == n) ans++;
}
}
}
cout << ans << endl;
return 0;
}
/*
output -> 2430
*/