# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1105996 | dzhoz0 | Savrsen (COCI17_savrsen) | C++17 | 303 ms | 78840 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
ghmt the cutie :3
UwU
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e18
#define f first
#define s second
#define pii pair<int, int>
#define vi vector<int>
const int MOD = 1'000'000'000 + 7;
void setIO(string name = "")
{
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#ifdef LOCAL
freopen("inp.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#else
if (!name.empty())
{
freopen((name + ".INP").c_str(), "r", stdin);
freopen((name + ".OUT").c_str(), "w", stdout);
}
#endif
}
const int MAXN = 1e7;
int sumFactor[MAXN + 5];
void init() {
memset(sumFactor, 0, sizeof(sumFactor));
for (int p = 1; p * p <= MAXN; p++) {
sumFactor[p * p] += p;
for (int q = p + 1; p * q <= MAXN; q++) sumFactor[p * q] += p + q;
}
}
void solve()
{
init();
int l, r; cin >> l >> r;
int res = 0;
for(int x = l; x <= r; x++) {
res += abs(2 * x - sumFactor[x]);
}
cout << res << '\n';
}
signed main()
{
setIO();
int t = 1;
// cin >> t;
while (t--)
solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |