As if it was a hash, direct enumeration will definitely time out.
The AB records must be divided into two groups.
Then find the corresponding CD
There are still many questions
For example, the end of * 16
And amazing STL
# Include <stdio. h> # include <string. h> # include <math. h> # include <iostream> # include <algorithm> # include <queue> # include <stack> # define MEM (a, B) memset (A, B, sizeof (A) # define ll _ int64 # define maxn 1000 # define INF 0x7ffffff # define lson L, M, RT <1 # define rson m + 1, R, RT <1 | 1 using namespace STD; int num1 [2, 12000]; int main () {int A, B, C, D, I, J; while (scanf ("% d", & A, & B, & C, & D )! = EOF) {int coun = 0; for (I = 1; I <= 100; I ++) {for (j = 1; j <= 100; j ++) {num1 [coun ++] = A * I * I + B * j;} Sort (num1, num1 + coun); int CNT = 0; for (I = 1; I <= 100; I ++) {for (j = 1; j <= 100; j ++) {int T; int temp = C * I * I + D * j; If (t = (upper_bound (num1, num1 + coun,-Temp)-lower_bound (num1, num1 + coun, -Temp) CNT + = T ;}} printf ("% d \ n", CNT * 16);} return 0 ;}