A quartile quadratic equation is used to give the values of a, B, c, d, and xi between [-100,100] but not equal to zero. How many solutions are there when the equation is equal to zero.
Questions can be violent... but they are always not harmonious.
Enumerate the possible values of a * x1 * x1 + B * x2 * x2 and hash them. Then, use hash to search for c * x3 * x3 + d * x4 * x4, multiply the Count value by 16 (xi can be positive or negative)
After a conflict is processed, the hash array can be much smaller, because the dual 100 loop has a maximum of 10000 different answers.
# Include <iostream> # include <algorithm> # include <cmath> # include <cstdio> # include <cstdlib> # include <cstring> # include <string> # include <vector> # include <set> # include <queue> # include <stack> # include <climits> // define MAX 50050 # define INF 0x7fffff # define REP (I, s, t) for (int I = (s); I <= (t); ++ I) # define ll long # define mem (a, B) memset (a, B, sizeof (a) # define mp (a, B) make_pa Ir (a, B) # define eps 1e-5 // # pragma comment (linker, "/STACK: 36777216") // The legendary plug-in using namespace std; int hash [MAX], cnt [MAX]; int HASH (int key) // handle conflicts {int t = key % MAX; if (t <0) t + = MAX; while (hash [t]! = Key & cnt [t]! = 0) {t = (t + 1) % MAX;} return t;} int main () {int a, B, c, d; while (scanf ("% d", & a, & B, & c, & d )! = EOF) {mem (hash, 0); mem (cnt, 0); if (a> 0 & B> 0 & c> 0 & d> 0) | (a <0 & B <0 & c <0 & d <0) {printf ("0 \ n"); continue;} REP (I, 1,100) {REP (j, 1,100) {int sum = a * I + B * j; int tmp = HASH (sum); hash [tmp] = sum; cnt [tmp] ++;} int ans = 0; REP (I, 1,100) {REP (j, 1,100) {int sum = c * I + d * j; int tmp = HASH (-sum); ans + = cnt [tmp] ;}} printf ("% d \ n", ans * 16);} return 0 ;}# include <iostrea M> # include <algorithm> # include <cmath> # include <cstdio> # include <cstdlib> # include <cstring> # include <string> # include <vector> # include <set> # include <queue> # include <stack> # include <climits> // # define MAX 50050 # define INF 0x7FFFFFFF # define REP (I, s, t) for (int I = (s); I <= (t); ++ I) # define ll long # define mem (a, B) memset (a, B, sizeof (a) # define mp (a, B) make_pair (a, B) # define eps 1e-5 // # pragma Comment (linker, "/STACK: 36777216") // The legendary plug-in using namespace std; int hash [MAX], cnt [MAX]; int HASH (int key) // handle the conflict {int t = key % MAX; if (t <0) t + = MAX; while (hash [t]! = Key & cnt [t]! = 0) {t = (t + 1) % MAX;} return t;} int main () {int a, B, c, d; while (scanf ("% d", & a, & B, & c, & d )! = EOF) {mem (hash, 0); mem (cnt, 0); if (a> 0 & B> 0 & c> 0 & d> 0) | (a <0 & B <0 & c <0 & d <0) {printf ("0 \ n"); continue;} REP (I, 1,100) {REP (j, 1,100) {int sum = a * I + B * j; int tmp = HASH (sum); hash [tmp] = sum; cnt [tmp] ++;} int ans = 0; REP (I, 1,100) {REP (j, 1,100) {int sum = c * I + d * j; int tmp = HASH (-sum); ans + = cnt [tmp] ;}} printf ("% d \ n", ans * 16);} return 0 ;}