找规律发现\( f[i]=f[i-1]+n-\sum_{i的因数和} \)一A了深(sh)蓝(ui)题的我被找规律绿题卡死
记得开long long
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1000005;
long long n,sum[N],f[N];
int main()
{
ios::sync_with_stdio(false);
scanf("%lld",&n);
for(long long i=1;i<=n;i++)
for(long long j=i;j<=n;j+=i)
sum[j]+=i;
f[1]=n-1;
for(long long i=2;i<=n;i++)
f[i]=f[i-1]+n-sum[i];
for(long long i=1;i<=n;i++)
printf("%lld ",f[i]);
return 0;
}