Machined Surfaces

From Progteam

Revision as of 00:02, 10 October 2008 by Mlc413 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Checkmark.jpg This problem has been solved by mlc413.


Machined Surfaces
Problem Number 1493
Sorter: mlc413
Source: Unknown
Link: http://acm.pku.edu.cn/JudgeOnline/problem?id=1493



Machined Surfaces is problem number 1493 on the Peking University ACM site.

import java.util.*;

public class Main{

    public static Scanner in;
 
    public static void main(String[] args){
        in=new Scanner(System.in);

        doStuff();
    }

    public static void doStuff(){
        int N=in.nextInt();

        while(N  != 0){
	    in.nextLine();
            solve(N);
	    N=in.nextInt();
        }
    }

    public static void solve(int N){
	String inline;
	int maxlen = 0; //Maximal number of Xs in a line
	int[][] machine = new int[25][N];
	int [] numXs = new int[N];
	
	//read input and determine length of closed machine
	for(int i =0; i < N; i++){
	    inline = in.nextLine();
	    int tmplen = 0;
	    for(int j =0; j < 25; j++){
		machine[j][i] = inline.charAt(j);
		if(machine[j][i] == 'X') tmplen++;
	    }
	    numXs[i] = tmplen;
	    if(tmplen>maxlen) maxlen = tmplen;
	}
	
	int innerspace = 0;
	for(int i = 0; i < N; i++){
	    innerspace += maxlen - numXs[i];
	}
	
	System.out.println(innerspace);
    }
}

Personal tools