1968: [Ahoi2005]COMMON 约数研究 Time Limit: 1 Sec Memory Limit: 64 MB Description Input 只有一行一个整数 N(0 < N < 1000000)。 Output 只有一行输出,为整数M,即f(1)到f(N)的累加和。 Sample Input 3 Sample Output 5 HINT Source Day2
#include<iostream>
#define LL long long
using namespace std;
int ans,x,y,tot=
0;
void slove(
int n)
{
int i=
1,j;
while(i<=n)
{
j=n/(n/i);
tot+=n/i*(j-i+
1);
i=j+
1;
}
return ;
}
int main()
{
cin>>x;
slove(x);
cout<<tot;
return 0;
}
转载请注明原文地址: https://ju.6miu.com/read-658360.html