Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <cstdio>
- #include <set>
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- #define sz size()
- #define all(x) (x).begin(),(x).end()
- #define pb push_back
- #define mp make_pair
- #define X first
- #define Y second
- #define abs(x) ((x) >= 0) ? (x) : -(x)
- #define sqr(x) ((x)*(x))
- bool good(long long n) {
- long long a = sqrt(n + .0);
- return (a * a == n);
- }
- int main() {
- long long a, n, sq, mn;
- cin >> a >> n;
- vector<long long> voc(a + n + 1, 1);
- for(int i = a; i <= a + n; i++) {
- if(good(i)) {
- voc[i] = i;
- }
- }
- long long mx = ceil(sqrt(a + n + 1.0));
- for(long long i = 2; i <= mx; i++) {
- sq = i * i;
- mn = (long long)(a / sq) * sq;
- for(int j = mn; j <= a + n; j += sq) {
- voc[j] = max(sq, voc[j]);
- }
- }
- sq = 0;
- for(int i = a; i < a + n; i++) {
- sq += i / voc[i];
- }
- cout << sq << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment