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
XXX XXXXXXX
XXXXX XXXX
XX XXXXXX
. .
. .
. .
XXXX XXXX
XXX XXXXXX
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:
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
相关推荐
这篇论文详细介绍了在微机械惯性传感器中应用的16位sigma-delta模数转换器(ADC)的设计与实现。Sigma-delta(Σ-∆)ADC是一种高分辨率模数转换技术,广泛应用于音频设备和传感器信号处理中。本文特别针对微机械...
微机电陀螺仪的数学模型和误差分析 在现代导航、航天航空和机器人技术等领域,陀螺仪是用于检测和测量角速度的关键元件。微机电陀螺仪是一种体积小巧、功耗低、成本相对低廉的陀螺仪类型,尤其适用于小型电子设备。...
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 ...
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"是一个独特的字体系列,它的设计理念、制作过程以及在各种...
如何使用它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 (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 系列配置说明书是关于...* CNC-machined钢格栅,提供了精准的制造 PRX412M-WH是一款高性能的utility/monitor扬声器,适用于多种应用场景,提供了出色的音质和可靠的性能。
本文专注于研究SiCp/Al复合材料的铣削加工表面粗糙度,旨在选取合适的表面特征参数。为此,研究团队对SiCp/Al复合材料进行了铣削实验,并利用OLS3000共聚焦激光扫描显微镜对加工后的表面形貌进行了测量。...
- 该传感器基于Infineon的专利bulk micro-machined传感技术,确保在恶劣环境下也能进行高度可靠的测量。 2. **压力测量**: - SP35提供了100至450kPa的压力测量范围。 - 包含了详细的测量规格说明,具体参数如...
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 ...
• 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...
超声振动辅助气体介质电火花加工硬质合金的材料去除机理,徐明刚、张建华等学者提出了一项新技术——超声振动辅助气体介质电火花加工(UEDMingas),并对其加工原理进行了阐述。为了实现这一技术,他们设计了相应的...
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)** - **浇...
尽管编撰者在收集信息时极其谨慎,但Engineered Machined Products, Inc.不对因手册中可能存在的任何错误或遗漏而导致的任何形式的损失承担责任。 - **变更声明**:手册内容可能会随时更新调整,且不事先通知。 ###...
- **Precision machined parts**: 通过精密加工技术制造的配件,适用于要求极高精度的行业,如电子、航天、汽车等。 - **Precision metal parts**: 主要是金属材质的精密部件,可以是定制的或标准的,用于各种精密...