UVA-414 machined surfaces (test instructions difficult to understand)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.