博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NUC1178 Kickdown
阅读量:7258 次
发布时间:2019-06-29

本文共 2709 字,大约阅读时间需要 9 分钟。

时间限制: 1000ms 内存限制: 65536KB

问题描述
A research laboratory of a world-leading automobile company has received an order to create a special transmission mechanism, which allows for incredibly efficient kickdown — an operation of switching to lower gear. After several months of research engineers found that the most efficient solution requires special gears with teeth and cavities placed non-uniformly. They calculated the optimal flanks of the gears. Now they want to perform some experiments to prove their findings.The first phase of the experiment is done with planar toothed sections, not round-shaped gears. A section of length n consists of n units. The unit is either a cavity of height h or a tooth of height 2h. Two sections are required for the experiment: one to emulate master gear (with teeth at the bottom) and one for the driven gear (with teeth at the top).
There is a long stripe of width 3h in the laboratory and its length is enough for cutting two engaged sections together. The sections are irregular but they may still be put together if shifted along each other.
The stripe is made of an expensive alloy, so the engineers want to use as little of it as possible. You need to find the minimal length of the stripe which is enough for cutting both sections simultaneously.
输入描述
There are two lines in the input file, each contains a string to describe a section. The first line describes master section (teeth at the bottom) and the second line describes driven section (teeth at the top). Each character in a string represents one section unit — 1 for a cavity and 2 for a tooth. The sections can not be flipped or rotated.Each string is non-empty and its length does not exceed 100.
输出描述
Write a single integer number to the output file — the minimal length of the stripe required to cut off given sections.
样例输入
sample input #121121121122212112sample input #21212121221212121sample input #3221122112221212
样例输出
sample output #110sample output #28sample output #315
来源
Northeastern Europe 2006
提示
注意:上面只是给出三个例子。 需要注意 input 中的“ There are two lines in the input file,...” 只有一组测试数据。不要输入“sample input #1”等标识符 和输出 “sample output #1”等标识符。

问题分析:

这个问题和《》是同一个问题,代码拿过来用就AC了。

程序说明:

参见参考链接。

参考链接:

题记:

程序做多了,不定哪天遇见似曾相识的。

AC的C++程序如下:

/* UVA1588 UVALive3712 POJ3158 Kickdown */    #include 
#include
#define MIN(x, y) (((x)>(y))?(y):(x)) #define MAXN 100 char s[MAXN], t[MAXN]; int main(void) { int slen, tlen, ans1, ans2, i, j; while(scanf("%s", s) != EOF) { scanf("%s", t); slen = strlen(s); tlen = strlen(t); /* s left, t right */ for(i=0; i

转载于:https://www.cnblogs.com/tigerisland/p/7563780.html

你可能感兴趣的文章
32.QT-制作最强电压电阻表盘,可以自定义阴影效果,渐变颜色,图标,文字标签等-附带demo程序...
查看>>
jquery tmpl 详解
查看>>
Linux iptables 命令
查看>>
bootstrap课程9 bootstrap如何实现动画加载进度条的效果
查看>>
Laravel 5.3 用户验证源码探究 (一) 路由与注册
查看>>
程序员考证之信息系统项目管理师
查看>>
scikit-learn学习笔记
查看>>
mybatis 传入多个参数
查看>>
opencv给图片添加文字水印<转>
查看>>
mysql查询表的数据大小
查看>>
初识Continuation
查看>>
smooth l1
查看>>
ET–异步协程使用–TimerComponent篇
查看>>
Linux LVM学习总结——Insufficient Free Extents for a Logical Volume
查看>>
智课雅思词汇---二十一、名词性后缀acity是什么意思
查看>>
JavaWeb 返回json数据的两种方式
查看>>
(转)Java 详解 JVM 工作原理和流程
查看>>
关于如何获得数据库数据变化的情况(比定时查询方便多了)
查看>>
阿里员工都是这样排查Java问题的,附工具单(转)
查看>>
用flutter写一个精美的登录页面
查看>>