Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const int MAXN = 3001;
- vector<int> divisors[MAXN];
- int main() {
- int n, x;
- cin >> n >> x;
- for (int i = 1; i <= n; ++i) {
- for (int j = 1; j * j <= i; ++j) {
- if (i % j == 0) {
- divisors[i].push_back(j);
- if (j * j != i) {
- divisors[i].push_back(i / j);
- }
- }
- }
- }
- int ans = 0;
- for (int dif1 = 1; dif1 < n; ++dif1) { // dif1 = (a-c)*b
- int dif2 = n - dif1; // dif2 = c*(b-d)
- for (int b : divisors[dif1]) {
- int a_minus_c = dif1 / b;
- for (int c : divisors[dif2]) {
- int b_minus_d = dif2 / c;
- int a = c + a_minus_c;
- int d = b - b_minus_d;
- if (a > c && b > d && c > 0 && d > 0 && a != x && b != x) {
- ++ans;
- }
- }
- }
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement