Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const short LOVE = 1411;
- const int N = 1e6;
- typedef long long ll;
- ll a[N + 1];
- ll b[N + 1];
- void query() {
- int l, r; cin >> l >> r;
- cout << b[r] - b[l - 1] << ' ' << a[r] - a[l - 1] << '\n';
- }
- int main(){
- //freopen("Test.INP", "r", stdin);
- //freopen("Test.OUT", "w", stdout);
- cin.tie(NULL)->sync_with_stdio(false);
- srand(time(0));
- for (int i = 1; i*i <= N; ++i) {
- a[i*i] += i, b[i*i] += 1;
- for (int j = i + 1; i*j <= N; ++j)
- a[i*j] += i + j, b[i*j] += 2;
- }
- for (int i = 2; i <= N; ++i)
- a[i] += a[i - 1], b[i] += b[i - 1];
- int t = 1; for (cin >> t; t--; query());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement