The main idea: a pxq lattice composed of p*q dots (forming a rectangle). Remove all points from the inner point of the two squares, which are equal in length, with respect to the centerline symmetry in the position, and the number of layers of the remaining points in the upper and lower left and right sides of each square. Now it is known that the number of points left to be removed from the remainder of S, the number of points may be taken away.
Problem analysis: When taking away the 2n^2 point, according to the conditions in the problem set, the number of points remaining is s=7nk+6k^k (where k is the number of layers). Enumeration k, can get n, problem solved.
The code is as follows:
# include<cstdio>using namespacestd;# define LLLong LongConstLL mod=100000007;intMain () {LL s; while(~SCANF ("%lld", &s) &&s) {intyy=1; for(LL k=1;6*k*k<s;++k) {LL U=s-6*k*K; if(u% (7*k) = =0) {LL n=u/(7*K)%MoD; printf ("Possible Missing soldiers =%lld\n", n*n*2%MoD); YY=0; } } if(yy) printf ("No Solution possible\n"); printf ("\ n"); } return 0;}
UVA-11490 Just Another problem