Understand that test instructions is a water problem.
Give you n rows each row has 25 characters, the first and last are ' X ', the middle may contain spaces, ask each time with the left (or right) to move, until there is no space in the middle, ask at this time how many spaces.
We directly consider the state after the move, it is definitely a small line of the first move, then as long as the total number of the original space minus the minimum space of the line by Xn is the remaining characters.
#include <cstdio> #include <cstring>int main () { int n,i,j,m,sum,maxn; Char s[30]; while (~SCANF ("%d", &n), N) { sum=0; maxn=25; GetChar (); for (i=0;i<n;i++) { m=0; Fgets (S,30,stdin); For (J=0;j<strlen (s); j + +) { if (s[j]== ') {m++;sum++;} } if (M<MAXN) maxn=m; } printf ("%d\n", sum-maxn*n); } return 0;}
UVA-414 machined surfaces (test instructions difficult to understand)