题解:
显然每一个数对答案的贡献为n/i
代码:
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
scanf("%d",&n);
int ans=;
for (int i=;i<=n;i++)ans+=n/i;
printf("%d",ans);
}
题解:
显然每一个数对答案的贡献为n/i
代码:
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
scanf("%d",&n);
int ans=;
for (int i=;i<=n;i++)ans+=n/i;
printf("%d",ans);
}