11490-Just Another Problem
Question Link
There are S soldiers in a matrix. There can be two holes in the matrix. The thickness of the two holes is the same between the top and bottom, and the number of soldiers is missing.
Idea: Push the formula, set the thickness to a and the square to I, then (3 a + 2 I) (2 a + I) = S + 2 I;
6 I + 7 a I = S.
Due to the large size of S, it is enough to enumerate the thickness of sqrt (S), and the complexity is acceptable.
Code:
# Include <stdio. h> # include <string. h> # include <math. h> const long MOD = 100000007; long n; int main () {while (~ Scanf ("% lld", & n) {int flag = 1; for (long I = 1; I * 6 <n; I ++) {long tmp = n-I * 6; if (tmp % (7 * I) = 0) {long ans = tmp/(7 * I) % MOD; printf ("Possible Missing Soldiers = % lld \ n", ans * 2% MOD); flag = 0 ;}} if (flag) printf ("No Solution Possible \ n"); printf ("\ n");} return 0 ;}