首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

11661 - Burger Time

2013-09-07 
11661 - Burger Time?Burger Time? Everybody knows that along the more important highways there are c

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 11661 - Burger Time 2000000) indicating the length of the highway.

The second line of each test case contains a string #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;}

热点排行