#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=1e7+5;
ll a, b, res, dp[nx];
bitset<nx> p;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>a>>b;
for (int i=1; i<=b; i++) dp[i]=1;
for (ll i=2; i<=b; i++)
{
if (p[i]) continue;
for (ll j=i; j<=b; j+=i)
{
p[j]=1;
ll tmp=1, mul=i;
while ((j%mul)==0) tmp+=mul, mul*=i;
dp[j]*=tmp;
}
}
//for (int i=1; i<=b; i++) cout<<"debug "<<dp[i]<<'\n';
for (int i=a; i<=b; i++) res+=abs(dp[i]-2*i);
cout<<res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
220 ms |
79708 KB |
Output is correct |
5 |
Correct |
225 ms |
79916 KB |
Output is correct |
6 |
Correct |
229 ms |
79932 KB |
Output is correct |
7 |
Correct |
201 ms |
74492 KB |
Output is correct |
8 |
Correct |
46 ms |
23132 KB |
Output is correct |