题解:考虑每个因子的贡献,n/d有√n种取值
O(√n)
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int ans;
int n;
int main(){
cin>>n;
for(int i=1;i<=n;++i)ans+=n/i;
cout<<ans<<endl;
return 0;
}
标签:ring class body 研究 题解 stream iostream name pre
题解:考虑每个因子的贡献,n/d有√n种取值
O(√n)
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int ans;
int n;
int main(){
cin>>n;
for(int i=1;i<=n;++i)ans+=n/i;
cout<<ans<<endl;
return 0;
}
BZOJ 1968 [Ahoi2005]COMMON 约数研究
标签:ring class body 研究 题解 stream iostream name pre
原文地址:https://www.cnblogs.com/zzyer/p/8456396.html