Description: I didn't understand the question at the beginning. I used to generate a number (x, y ), make x ^ 2 + y ^ 2 = s ^ 2 # include <cstdio> # include <cstring> int V [310] [310], arr [45] [2]; int pow_two (int x, int y) {return x * x + y * Y;} int main () {// freopen ("a.txt", "r", stdin ); int n, m, T, sum, count; scanf ("% d", & T); While (t --) {memset (v, 0, sizeof (V )); V [0] [0] = 1; scanf ("% d", & N, & M); int X, Y; sum = m * m; count = 0; For (INT I = 0; I <n; I ++) {scanf ("% d", & X, & Y ); for (Int J = 0; j <m; j ++) for (int K = 0 ; K <m; k ++) if (V [J] [k] & pow_two (x + J, Y + k) <= sum &&(! V [J + x] [Y + k] | V [J + x] [K + Y]> V [J] [k] + 1 )) {v [J + x] [Y + k] = V [J] [k] + 1; if (pow_two (x + J, Y + k) = sum &&(! Count | count> V [J + x] [Y + k]) Count = V [J + x] [Y + k] ;}} if (count) printf ("% d \ n", Count-1); else puts ("not possible");} return 0 ;}