Question:
Given a rectangle, the number of tangent circles in which the radius and center of the rectangle are integers.
Solution:
Look for a rectangle again and kneel down... The original rectangle is so useful ..
Enumerate the right-angle triangle sides to obtain the oblique edge. Enumerate the circle radius of the endpoint at the oblique endpoint and tangent at the oblique edge. A fixed rectangle is obtained from a fixed Oblique Edge and two circles. 2 is required for each rectangle due to symmetry.
In another case, if one side of a right triangle is 0, the oblique side of the enumeration is parallel to the rectangular side, and only 1 is added.
# Include <stdio. h> # include <string. h> # include <math. h> # include <map> # include <string> # include <vector> # include <set> # include <algorithm> using namespace STD; const int maxn = 1011; short int f [2000010]; int data [maxn] [maxn]; int G [maxn] [maxn]; void Init () {for (INT I = 0; I * I <= 2000000; I ++) f [I * I] = I; for (INT x = 0; x <maxn; X ++) {for (INT y = (x = 0); y <maxn; y ++) {int T = x * x + y * Y; t = f [T]; for (INT R0 = 1; R0 <t; R0 ++) {int R1 = T-R0; int u = max (x + R0 + R1, 2 * max (r0, r1); int v = max (Y + R0 + R1, 2 * max (r0, R1); If (U <1001 & V <= 1001) G [u] [v] + = 1 + (X & Y) ;}}} int main () {Init (); int Kase ,__ = 1; scanf ("% d", & Kase); While (Kase --) {int n, m; long ans = 0; scanf ("% d", & N, & M); For (INT x = 1; x <= N; X ++) for (INT y = 1; y <= m; y ++) ans = ans + (long) g [x] [Y] * (N-x + 1) * (m-y + 1); printf ("case % d: % LLD \ n ",__ ++, ANS);} return 0 ;}