Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define F first
  6. #define S second
  7. #define L first
  8. #define R second
  9. #define X real()
  10. #define Y imag()
  11. #define pb push_back
  12. #define pf push_front
  13. #define cel(a, b) ((a) / (b) + ((a % b == 0) ? 0 : 1))
  14.  
  15. typedef long long ll;
  16. typedef long double ld;
  17. typedef pair<int, int> pii;
  18. typedef pair<ll, ll> pll;
  19. typedef complex<ld> point;
  20.  
  21. const int MAX = 1001000;
  22.  
  23. ll a, b;
  24. ll f[MAX], n[MAX];
  25. bool vis[MAX];
  26.  
  27. int main() {
  28. cin >> a >> b;
  29. for (ll i = 0; i <= b - a; i++)
  30. f[i] = 1, n[i] = i + a;
  31. for (ll p = 2; p * p <= b; p++) {
  32. if (vis[p])
  33. continue;
  34. for (ll x = p; x < MAX; x += p)
  35. vis[x] = true;
  36. for (ll x = cel(a, p) * p; x <= b; x += p) {
  37. ll &t = n[x - a], q = 1, s = 1;
  38. while (t % p == 0)
  39. t /= p, q *= p, s += q;
  40. f[x - a] *= s;
  41. }
  42. }
  43. for (ll i = 0; i <= b - a; i++) {
  44. if (n[i] != 1)
  45. f[i] *= 1ll + n[i];
  46. }
  47. ll ans = 0;
  48. for (ll i = 0; i <= b - a; i++)
  49. ans += f[i];
  50. cout << ans << endl;
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement