`
hellobin
  • 浏览: 65481 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

UVA 414 - Machined Surfaces

    博客分类:
  • UVA
 
阅读更多

An imaging device furnishes digital images of two machined surfaces that eventually will be assembled in contact with each other. The roughness of this final contact is to be estimated.

 

A digital image is composed of the two characters,"X"and" "(space). There are always 25 columns to an image, but the number of rows,N, is variable. Column one (1) will always have an"X"in it and will be part of the left surface. The left surface can extend to the right from column one (1) as contiguousX's.

 

Similarly, column 25 will always have an"X"in it and will be part of the right surface. The right surface can extend to the left from column 25 as contiguousX's.

Digital-Image View of Surfaces

 

 
		 Left     		                           Right

 

XXXX XXXXX tex2html_wrap_inline50

XXX XXXXXXX

XXXXX XXXX

XX XXXXXX

. .

. .

. .

XXXX XXXX

XXX XXXXXX tex2html_wrap_inline52

tex2html_wrap_inline54tex2html_wrap_inline56

1 25

In each row of the image, there can be zero or more space characters separating the left surface from the right surface. There will never be more than a single blankregionin any row.

 

For each image given, you are to determine the total ``void" that will exist after the left surface has been brought into contact with the right surface. The ``void" is the total count of the spaces that remains between the left and right surfaces after theyhave been brought into contact.

 

The two surfaces are brought into contact by displacing them strictly horizontally towards each other until a rightmost"X"of the left surface of some row is immediately to the left of the leftmost"X"of the right surface of that row. There is no rotation or twisting of these two surfaces as they are brought into contact; they remain rigid, and only move horizontally.

 

 

Note:The original image may show the two surfaces already in contact, in which case no displacement enters into the contact roughness estimation.

 

Input

The input consists of a series of digital images. Each image data set has the following format:

 

First line -
A single unsigned integer,N, with value greater than zero (0) and less than 13. The first digit ofNwill be the first character on a line.

 

NextNlines -
Each line has exactly 25 characters; one or moreX's, then zero or more spaces, then one or moreX's.

 

The end of data is signaled by a null data set having a zero on the first line of an image data set and no further data.

 

Output

For each image you receive as a data set, you are to reply with the total void (count of spaces remaining after the surfaces are brought into contact). Use the default output for a single integer on a line.

 

Sample Input(character"B"for ease of reading. The actual input file will use the ASCII-space character, not"B").

 

4
XXXXBBBBBBBBBBBBBBBBXXXXX
XXXBBBBBBBBBBBBBBBXXXXXXX
XXXXXBBBBBBBBBBBBBBBBXXXX
XXBBBBBBBBBBBBBBBBBXXXXXX
2
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXBBBBBBBBBBBBBBXX
0

 

Sample Output

 

4
0
0

总结
1)空格是' '而不是'B'
2)fgets会读入'\n', scanf只会读到空白(' ','\n',etc)之前,需要用getchar()来读过回车



#define RUN
#ifdef RUN

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <cctype> 
#include <algorithm>
#include <utility>
#include <math.h>

using namespace std;

#define MAXN 1000

char input[MAXN];
int empty[14];

int main(){

#ifndef ONLINE_JUDGE
	freopen("414.in", "r", stdin);
	freopen("414.out", "w", stdout); 
#endif

	
	int n;

	while(scanf("%d", &n)==1 && (n!=0)){
		// Read '\n'
		getchar();
		int minEmpty = 32767;
		memset(empty, 0, sizeof(empty));
		for(int i=0; i<n; i++){
			memset(input, 0, sizeof(input));

			fgets(input, MAXN, stdin);
			//scanf("%s", input);
			//printf("%s\n", input);

			// Count the number of empty spaces ' ' in the input string
			for(int j=0; j<strlen(input); j++){
				if(input[j] == ' '){
					empty[i]++;
				}
			}

			// Get the minimum number of Bs
			if(empty[i] < minEmpty){
				minEmpty = empty[i];
			}
		}

		int remain = 0;
		for(int i=0; i<n; i++){
			remain += (empty[i]-minEmpty);
		}

		printf("%d\n", remain);
	}




}


#endif

分享到:
评论

相关推荐

    A 16-bit sigma-delta ADC applied in micro-machined inertial sensor

    这篇论文详细介绍了在微机械惯性传感器中应用的16位sigma-delta模数转换器(ADC)的设计与实现。Sigma-delta(Σ-∆)ADC是一种高分辨率模数转换技术,广泛应用于音频设备和传感器信号处理中。本文特别针对微机械...

    Micro-machined gyroscope mathematical model and error analysis.

    微机电陀螺仪的数学模型和误差分析 在现代导航、航天航空和机器人技术等领域,陀螺仪是用于检测和测量角速度的关键元件。微机电陀螺仪是一种体积小巧、功耗低、成本相对低廉的陀螺仪类型,尤其适用于小型电子设备。...

    A micro-machined thin film electro-acoustic biosensor for detection of pesticide residuals

    Increasing awareness concerning food safety problems has been driving the search for simple and efficient biochemical analytical methods. In this paper, we develop a portable electro-acoustic ...

    Development of high damage threshold laser-machined apodizers and gain filters for laser applications

    We have developed high damage threshold filters to modify the spatial profile of a high energy laser beam. The filters are formed by laser ablation of a transmissive window. The ablation sites ...

    Machined

    《Machined:深入探索字体设计的艺术与技术》 在数字化的世界中,字体设计扮演着至关重要的角色,它不仅传达信息,更影响着阅读体验和视觉感受。"Machined"是一个独特的字体系列,它的设计理念、制作过程以及在各种...

    nspawn:围绕machinectl的包装器,可轻松部署nspawn.org容器

    如何使用它nspawn {COMMAND} [PARAMETER]Wrapper around systemd-machined and https://nspawn.orgCommands: init Initializes an image for systemd-machined with the following parameters: ...

    Micro Fabry-Perot interferometers in silica fibers machined by femtosecond laser

    Micro Fabry-Perot (F-P) interferometers (MFPIs) are machined in a single-mode fiber (SMF) and a photonic crystal fiber (PCF) by using a near-infrared femtosecond laser, respectively. The strain and ...

    JBL PRX400 系列配置说明书.pdf

    JBL PRX400 系列配置说明书.pdf JBL PRX400 系列配置说明书是关于...* CNC-machined钢格栅,提供了精准的制造 PRX412M-WH是一款高性能的utility/monitor扬声器,适用于多种应用场景,提供了出色的音质和可靠的性能。

    Choice of reference surfaces for machined surface roughness in milling of SiCp/Al composites

    本文专注于研究SiCp/Al复合材料的铣削加工表面粗糙度,旨在选取合适的表面特征参数。为此,研究团队对SiCp/Al复合材料进行了铣削实验,并利用OLS3000共聚焦激光扫描显微镜对加工后的表面形貌进行了测量。...

    SP35数据手册说明.pdf

    - 该传感器基于Infineon的专利bulk micro-machined传感技术,确保在恶劣环境下也能进行高度可靠的测量。 2. **压力测量**: - SP35提供了100至450kPa的压力测量范围。 - 包含了详细的测量规格说明,具体参数如...

    Cylindrical Grinding - A Review on Surface Integrity

    The very nature of the grinding mechanism in material removal impairs the grounded surfaces by inducing residual stress, micro cracks and other thermal damages at the machined surface. This paper is ...

    MIL-DTL-26482

    • Pin and socket contacts are machined from low loss copper alloy and gold plated to eliminate contact corrosion and provide an indefinite shelf life. • All have resilient inserts which provide high...

    Material Removal Mechanisms of Cemented Carbides Machined by Ultrasonic Vibration Assisted EDM in Gas Medium

    超声振动辅助气体介质电火花加工硬质合金的材料去除机理,徐明刚、张建华等学者提出了一项新技术——超声振动辅助气体介质电火花加工(UEDMingas),并对其加工原理进行了阐述。为了实现这一技术,他们设计了相应的...

    DeskProto.6英文正式版

    Set a bottom level (the minimum Z-value to be machined). Define and select cutters Distance between the parallel toolpaths, and stepsize along the toolpath Speeds: feedrate and spindle speed ...

    模具设计专业术语

    - **精加工板(Finish Machined Plate)** - **固定支承板(Fixed Bolster Plate)** - **法兰销(Flanged Pin)** - **飞边浇口(Flash Gate)** - **沙漏模具(Flask)** - **浮动冲头(Floating Punch)** - **浇...

    EMP水泵CAN通信资料手册

    尽管编撰者在收集信息时极其谨慎,但Engineered Machined Products, Inc.不对因手册中可能存在的任何错误或遗漏而导致的任何形式的损失承担责任。 - **变更声明**:手册内容可能会随时更新调整,且不事先通知。 ###...

    机械行业的外贸关键词分析.doc

    - **Precision machined parts**: 通过精密加工技术制造的配件,适用于要求极高精度的行业,如电子、航天、汽车等。 - **Precision metal parts**: 主要是金属材质的精密部件,可以是定制的或标准的,用于各种精密...

Global site tag (gtag.js) - Google Analytics