11661 - Burger Time?
Burger Time? |
Everybody knows that along the more important highways there are countless fast food restaurants. One can find easily hamburgers, hot dogs, pizzas, sandwiches ... food everywhere.
Many times the problem isn't to find a restaurant but a drugstore. After a big lunch with fast food it's normal that we need a drugstore because our stomach begins to feel pain.
Given the locations of the restaurants and drugstores on a highway, you want to determine the minimum distance between a restaurant and a drugstore.
Input
The first line of each test case gives an integer L ( 1 L 2000000) indicating the length of the highway.
The second line of each test case contains a string S of length L, showing the positions of the restaurants and drugstores along the highway in the following manner:
- The character ``R'' represents a place with a restaurant.
- The character ``D'' represents a place with a drugstore.
- The character ``Z'' represents a place with a restaurant and a drugstore.
- The character ``.'' represents an empty place.
You can suppose that every test case has at least one restaurant and at least one drugstore.
The end of the input is indicated when L = 0.
Output
For each case in the input, print one line with the minimum distance between a restaurant and a drugstore.
Sample Input
2
RD
5
..Z..
10
.R......D.
10
.R..Z...D.
10
...D..R...
25
..D...R.RR...DD...D.R...R
0
Sample Output
1
0
7
0
3
2
#include<cstdio>
#include<algorithm>
using namespace std;
char a[2000005];
int main()
{
int n,i,j;
while(scanf("%d",&n)&&n)
{
int mind=2000005,j=0;
scanf("%s",a);
for(i=0;i<n;i++)
{
if(a[i]=='Z') mind=0;
if(a[i]!='.')
{
if(a[j]!='.'&&a[i]!=a[j])
mind=min(mind,i-j);
j=i;
}
}
printf("%d\n",mind);
}
return 0;
}
11661 - Burger Time?的更多相关文章
- UVA 557 Burger 排列组合递推
When Mr. and Mrs. Clinton's twin sons Ben and Bill had their tenth birthday, the party was held at t ...
- UVA 557 - Burger(概率 递推)
Burger When Mr. and Mrs. Clinton's twin sons Ben and Bill had their tenth birthday, the party was ...
- HDU 5948 Thickest Burger 【模拟】 (2016ACM/ICPC亚洲区沈阳站)
Thickest Burger Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- 「UVA557」 Burger(概率
本题征求翻译.如果你能提供翻译或者题意简述,请 提交翻译 ,感谢你的贡献. 题目描述 PDF 输入输出格式 输入格式: 输出格式: 输入输出样例 输入样例#1: 复制 3 6 10 256 输出样例# ...
- Burger King使用RayOnSpark进行基于实时情景特征的快餐食品推荐
作者:Luyang Wang, Kai Huang, Jiao Wang, Shengsheng Huang, Jason Dai 基于深度学习的推荐模型已广泛应用于各种电商平台中,为用户提供推荐.目 ...
- ROS开源小车TurtleBot3详情介绍(Burger)
您为什么要选择ROS开源智能小车 ROS(RobotOperating System,机器人操作系统)是目前世界上更主流更多人使用的的机器人开源操作系统.它可以提供操作系统应有的服务,包括硬件抽象,底 ...
- UVa 557 (概率 递推) Burger
题意: 有两种汉堡给2n个孩子吃,每个孩子在吃之前要抛硬币决定吃哪一种汉堡.如果只剩一种汉堡,就不用抛硬币了. 求最后两个孩子吃到同一种汉堡的概率. 分析: 可以从反面思考,求最后两个孩子吃到不同汉堡 ...
- UVA557 汉堡 Burger
题面 https://www.luogu.org/problemnew/show/UVA557 这里顺便整理一下二维格点随机游走问题. 遇到这种问题时,需注意分母的计算问题. 设x为起点到终点的距离. ...
- uva 557 Burger
https://vjudge.net/problem/UVA-557 题意: n个人,n/2个牛肉煲,n/2个鸡肉堡 每次抛硬币,根据正反决定每个人吃什么汉堡 如果某一个汉堡被选完了,就不抛了 问最后 ...
随机推荐
- win7 php 配置多个网站
1.在C:\WINDOWS\system32\drivers\etc目录下,打开Hosts 添加A站和B站的DNS映射,如127.0.0.1 local.zhengxin.com127.0.0.1 l ...
- Javascript常用函数收集(不定期更新)
str.replace('/正则表达式/','替换内容'); //正则替换str.match('/正则表达式/','替换内容'); //正则匹配 str.indexOf('查找代码'); //查找是否 ...
- jquery倒计时自动跳转
刚开始我用下面这种方法一直报错,不知是什么原因,就是多加了页面加载时调用这个方法,还请高手看到后小小留言解惑
- Visual Studio 2015编译安装配置QT5.5.1(含QTWEBKIT)
尽管QT5.5.1和VisualStudio 2015都已经发布很久了,但是QT项目组视乎不会为QT5.5.1专门发布预编译的QT5.5.1 for windows(2015)版本的,也不会专门发布V ...
- 简单实用的下拉菜单(CSS+jquery)
原文 简单实用的下拉菜单(CSS+jquery) 没什么可以说的,直接上例子 html+jquery代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTM ...
- URAL 1820. Ural Steaks(数学啊 )
题目链接:space=1&num=1820" target="_blank">http://acm.timus.ru/problem.aspx? space ...
- 具体解释EBS接口开发之WIP模块接口
整体说明 文档目的 本文档针对WIP模块业务功能和接口进行分析和研究,对採用并发请求方式和调用API方式分别进行介绍 内容 WIP模块经常使用标准表简单介绍 WIP事物处理组成 WIP相关业务流程 W ...
- QTP实践总结
QTP实践总结 查询数据库修改freq 1.Testcasetable创建查询select * from testcasetable order by fseq desc 2.设计表-选项-修改自动递 ...
- Inter IPP 跟 Microsoft V100编译器区别
最近做项目用了两个编译器,由于是一种精度的算法计算,对计算的精度要求非常高,同时都用的float型,发现inter的结果比vs的结果好许多.但是不知道是什么原因,最后测试发现,是两个编译器的问题. ...
- [转]Linux(centOS6.5)下SVN的安装、配置及开机启动
1.检查是否已安装 rpm -qa subversion 如果要卸载旧版本: yum remove subversion 2.安装 yum install subversion PS:yum inst ...