|
|
@ -4,7 +4,7 @@ using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
typedef long long LL;
|
|
|
|
typedef long long LL;
|
|
|
|
const int N = 1e5 + 10;
|
|
|
|
const int N = 1e5 + 10;
|
|
|
|
int n = 27;
|
|
|
|
int n = 20;
|
|
|
|
|
|
|
|
|
|
|
|
// 筛法求莫比乌斯函数(枚举约数)
|
|
|
|
// 筛法求莫比乌斯函数(枚举约数)
|
|
|
|
LL mu[N], sum[N];
|
|
|
|
LL mu[N], sum[N];
|
|
|
@ -55,26 +55,27 @@ int getmob(LL x) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
int main() {
|
|
|
|
|
|
|
|
// 计算单个数字的莫比乌斯函数
|
|
|
|
|
|
|
|
for (int i = 1; i <= n; i++) printf("%2d ", getmob(i));
|
|
|
|
|
|
|
|
cout << endl;
|
|
|
|
|
|
|
|
for (int i = 1; i <= n; i++) printf("%2d ", i);
|
|
|
|
|
|
|
|
|
|
|
|
// 筛法求莫比乌斯函数
|
|
|
|
// 筛法求莫比乌斯函数
|
|
|
|
get_mobius1(n);
|
|
|
|
// get_mobius1(n);
|
|
|
|
|
|
|
|
// for (int i = 1; i <= n; i++)
|
|
|
|
|
|
|
|
// cout << "mu1[" << i << "]=" << mu[i] << endl;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= n; i++) {
|
|
|
|
// //清空一下,继续测试
|
|
|
|
//计算单个数字的莫比乌斯函数
|
|
|
|
// memset(mu, 0, sizeof mu);
|
|
|
|
cout << "mu1[" << i << "]=" << getmob(i) << endl;
|
|
|
|
|
|
|
|
cout << "mu1[" << i << "]=" << mu[i] << endl;
|
|
|
|
|
|
|
|
cout << "========================================" << endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//清空一下,继续测试
|
|
|
|
|
|
|
|
memset(mu, 0, sizeof mu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//测试枚举约数的筛法
|
|
|
|
// //测试枚举约数的筛法
|
|
|
|
get_mobius2(n);
|
|
|
|
// get_mobius2(n);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= n; i++) {
|
|
|
|
// for (int i = 1; i <= n; i++) {
|
|
|
|
//计算单个数字的莫比乌斯函数
|
|
|
|
// //计算单个数字的莫比乌斯函数
|
|
|
|
cout << "mu2[" << i << "]=" << getmob(i) << endl;
|
|
|
|
// cout << "mu2[" << i << "]=" << getmob(i) << endl;
|
|
|
|
cout << "mu2[" << i << "]=" << mu[i] << endl;
|
|
|
|
// cout << "mu2[" << i << "]=" << mu[i] << endl;
|
|
|
|
cout << "========================================" << endl;
|
|
|
|
// cout << "========================================" << endl;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|