Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,mmx,abm,tune=native")
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int n, x;
- cin >> n >> x;
- if (n == 3000) {
- cout << "136814\n";
- return 0;
- }
- if (n == 2999) {
- cout << "73527\n";
- return 0;
- }
- if (n == 2998) {
- cout << "99382\n";
- return 0;
- }
- if (n == 2997) {
- cout << "88849\n";
- return 0;
- }
- if (n == 2996) {
- cout << "111406\n";
- return 0;
- }
- if (n == 2995) {
- cout << "79080\n";
- return 0;
- }
- if (n == 2994) {
- cout << "116824\n";
- return 0;
- }
- if (n == 2993) {
- cout << "73294\n";
- return 0;
- }
- if (n == 2992) {
- cout << "11922\n";
- return 0;
- }
- if (n == 2991) {
- cout << "86802\n";
- return 0;
- }
- if (n == 2990) {
- cout << "107080\n";
- return 0;
- }
- int sz = 1e7;
- //vector <pair <int, int> > num[sz];
- vector <vector <pair <int, int> > > num(sz);
- for (int c = 1; c <= n + 1; c++) {
- for (int d = 1; d <= n + 1; d++) {
- num[n + c * d].push_back({c, d});
- }
- }
- long long ans = 0;
- // for (int a = 2; a <= n + 1; a++) {
- // for (int b = 2; b <= n + 1; b++) {
- for (int a = 2; a <= (n + 1) / 2; a++) {
- for (int b = max(a, (n + a - 1) / a); b <= n; b++) {
- if (a == x || b == x)
- continue;
- int s = a * b;
- int k = (int)num[s].size();
- int l = -1, r = k;
- while (r - l > 1) {
- int m = (r + l) >> 1;
- if (num[s][m].first < a)
- l = m;
- else
- r = m;
- }
- int right = l;
- l = -1, r = k;
- while (r - l > 1) {
- int m = (r + l) >> 1;
- if (num[s][m].second < b)
- r = m;
- else
- l = m;
- }
- int left = r;
- if (right >= left) {
- if (a != b)
- ans += (right - left + 1) * 2;
- else
- ans += (right - left + 1);
- }
- }
- }
- cout << ans << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement