# Machined Surfaces

### From Progteam

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); } }