Do you:
1: Input n, ask (A, b) to meet a < b and exist x, y so that x*a + y*b = N of the two-tuple number, require N, a, b, X, y are all positive integers
2 method: First preprocessing less than N of the number of divisors, and then the violent temptation + pruning, the test of the number of two groups, the time complexity 1/x from 1 to n integral, for NLN (n)
Vjudge Topic link
Recommended Reference Blog 1
Recommended Reference Blog 2
The following is the accepted code
#include <bits/stdc++.h> using namespace std;
const int N = 3e5 + 4;
Vector <int> Y_b[n];
Vector <int>:: iterator B;
int book[n];
int main () {int n, I, J, a, X, T, ans;
scanf ("%d", &n); for (i = 1; I <= n; i++) {for (j = 1; j*j <= i; j +) {if (i%j = 0) {Y_b[i].push_ba
CK (j);
if (I*i!= j) {t = i/j;
Y_b[i].push_back (t);
Sort (Y_b[i].begin (), Y_b[i].end (), greater<int> ());
Ans = 0;
for (a = 1; a < n; a++) {for (x = 1; x*a < n x + +) {t = n-x*a;
for (b = Y_b[t].begin (), B!= y_b[t].end (); b++) {if ((*b) <= a) break;
if (Book[*b]!= a) {ans++;
BOOK[*B] = A;
}} printf ("%d\n", ans);
return 0;
}
The following is the recommended reference code
#include <bits/stdc++.h> using namespace std;
const int N = 3e5 + 4;
Vector <int> y_b[n];/* Records the divisors of the current element/vector <int>:: iterator B;
int book[n];/* real-type global variable initialization defaults to 0*/BOOL CMP (int a, int b) {return a > B;}
int main () {int n, I, J, a, X, T, ans;
scanf ("%d", &n); for (i = 1; I <= n; i++) {for (j = 1; j*j <= i; j +) {if (i%j = 0) {Y_b[i].push_ba
CK (j);
if (I*i!= j) {t = i/j;
Y_b[i].push_back (t);
Sort (Y_b[i].begin (), Y_b[i].end (), greater<int> ());
Ans = 0;
for (a = 1; a < n; a++) {for (x = 1; x*a < n x + +) {t = n-x*a; for (b = Y_b[t].begin (); b!= Y_b[t].end (); b++) {if (*b) <= a) *: A < b*/break
;
if (Book[*b]!= a) {/* Mark heavy */ans++;
BOOK[*B] = A; }} printf ("%d\n", ans);
return 0;
}