Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6.  
  7. const int MAXN = 3001;
  8. vector<int> divisors[MAXN];
  9.  
  10. int main() {
  11.     int n, x;
  12.     cin >> n >> x;
  13.     for (int i = 1; i <= n; ++i) {
  14.         for (int j = 1; j * j <= i; ++j) {
  15.             if (i % j == 0) {
  16.                 divisors[i].push_back(j);
  17.                 if (j * j != i) {
  18.                     divisors[i].push_back(i / j);
  19.                 }
  20.             }
  21.         }
  22.     }
  23.     int ans = 0;
  24.     for (int dif1 = 1; dif1 < n; ++dif1) { // dif1 = (a-c)*b
  25.         int dif2 = n - dif1; // dif2 = c*(b-d)
  26.         for (int b : divisors[dif1]) {
  27.             int a_minus_c = dif1 / b;
  28.             for (int c : divisors[dif2]) {
  29.                 int b_minus_d = dif2 / c;
  30.                 int a = c + a_minus_c;
  31.                 int d = b - b_minus_d;
  32.                 if (a > c && b > d && c > 0 && d > 0 && a != x && b != x) {
  33.                     ++ans;
  34.                 }
  35.             }
  36.         }
  37.     }
  38.     cout << ans << endl;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement