#include <bits/stdc++.h>
#define ld long double
#define ll long long
#define sz size()
#define all(xx) xx.begin(),xx.end()
#define pb push_back
#define in insert
#define er erase
#define S second
#define F first
#define pii pair <int, int>
#define to_be continue
#define mp make_pair
#define stop exit (0)
#define fname ""
#define speed ios_base::sync_with_stdio(0);cin.tie(0)
#define input freopen (fname".in", "r", stdin)
#define output freopen (fname".out", "w", stdout)
#define int ll
#define N 20000000
using namespace std;
const int inf = 1e9 + 123;
const ll INF = 1e18 + 123;
const double pi = acos (-1.0);
const ld eps = 1e-3;
int a, b, sum, f[N];
main ()
{
speed;
cin >> a >> b;
f[1] = 1;
for (int i = 2; i <= 1e7 + 123; i ++)
f[i] = i - 1;
for (int i = 2; i <= 1e7 + 123; i ++)
{
for (int j = i + i; j <= 1e7 + 123; j += i)
{
f[j] -= i;
}
}
for (int i = a; i <= b; i ++)
sum += abs (f[i]);
cout << sum;
}
//Coded by A....
Compilation message
savrsen.cpp:32:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main ()
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2193 ms |
78584 KB |
Output is correct |
2 |
Correct |
2139 ms |
78736 KB |
Output is correct |
3 |
Correct |
2084 ms |
78912 KB |
Output is correct |
4 |
Correct |
2073 ms |
78912 KB |
Output is correct |
5 |
Correct |
2072 ms |
78912 KB |
Output is correct |
6 |
Correct |
2073 ms |
78912 KB |
Output is correct |
7 |
Correct |
2177 ms |
79004 KB |
Output is correct |
8 |
Correct |
2061 ms |
79128 KB |
Output is correct |