UVA 414 - Machined Surfaces Solution

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    char s[26];
    while (scanf("%d",&n)==1)
    {
        if (!n) return 0;
        int max_x=0;
        int total_x=0;
        getchar();
        for (int i=0;i<n;i++)
        {
            gets(s);
            int cnt=0;
            for (int j=0;j<25;j++)
            {
                if (s[j]=='X') cnt++;
            }
            total_x+=cnt;
            max_x=max(max_x,cnt);
        }
        int ans=max_x*n-total_x;
        printf("%d\n",ans);
    }
    return 0;
}

Comments

Popular posts from this blog

Codeforces 698A - Vacations

UVA 11364: Parking -Solution

UVA 11503 - Virtual Friends Solution