POJ 1250 模拟题

原创 2012年03月22日 11:23:35

     终于在POJ上碰到一道简单题,,不容易啊。。模拟,可以轻松水过。。题目:

Tanning Salon
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 5582   Accepted: 3052

Description

Tan Your Hide, Inc., owns several coin-operated tanning salons. Research has shown that if a customer arrives and there are no beds available, the customer will turn around and leave, thus costing the company a sale. Your task is to write a program that tells the company how many customers left without tanning. 

Input

The input consists of data for one or more salons, followed by a line containing the number 0 that signals the end of the input. Data for each salon is a single line containing a positive integer, representing the number of tanning beds in the salon, followed by a space, followed by a sequence of uppercase letters. Letters in the sequence occur in pairs. The first occurrence indicates the arrival of a customer, the second indicates the departure of that same customer. No letter will occur in more than one pair. Customers who leave without tanning always depart before customers who are currently tanning. There are at most 20 beds per salon. 

Output

For each salon, output a sentence telling how many customers, if any, walked away. Use the exact format shown below. 

Sample Input

2 ABBAJJKZKZ
3 GACCBDDBAGEE
3 GACCBGDDBAEE
1 ABCBCA
0

Sample Output

All customers tanned successfully.
1 customer(s) walked away.
All customers tanned successfully.
2 customer(s) walked away.
ac代码:

#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int numbed,visted[30];
int main(){
	//freopen("11.txt","r",stdin);
	while(scanf("%d",&numbed),numbed){
	  memset(visted,0,sizeof(visted));
	  string ss;
	  cin>>ss;
	  int num=numbed;
	  int sum=0;
	  int len=ss.size();
	  for(int i=0;i<len;++i){
		  if(visted[ss[i]-'A']==2)
			  continue;
		  else if(num<=0&&!visted[ss[i]-'A']){sum++;visted[ss[i]-'A']=2;}
		  else if(!visted[ss[i]-'A']&&num){
		    visted[ss[i]-'A']=1;
			num--;
		  }
		  else if(visted[ss[i]-'A']){
		    num++;
		  }
	  }
	  if(sum==0)printf("All customers tanned successfully.\n");
	  else printf("%d customer(s) walked away.\n",sum);
	}
  return 0;
}


poj模拟题(二分查找)

  • 2014年07月22日 19:32
  • 420KB
  • 下载

POJ 1033 磁盘文件碎片整理 模拟题 栈应用

以后一定要细心,不能再犯这个低级的错误,把WA控制在最低范围内 参考了 http://www.cnblogs.com/damacheng/archive/2010/09/24/1833983.htm...

POJ - 1835 宇航员(模拟题)

问题描述:   宇航员在太空中迷失了方向,在他的起始位置现在建立一个虚拟xyz坐标系,称为绝对坐标系,宇航员正面的方向为x轴正方向,头顶方向为z轴正方向,则宇航员的初始状态如下图所示:   现对...

poj 1009 这哪是模拟题啊?

一看题目感觉就是模拟题,但是直接模拟肯定超时超内存。但是压缩,又想不明白。 看了很多人的想法,感觉这个不错。就是将变化的点当做一个3*3矩阵中的中间点来算。同时将周围的8个点的相关情况也计算出来。 ...

POJ 1102 经典模拟题(例举两种方法)

【题意简述】:打印数字,主要注意格式控制! 【思路】:基本模拟题,注意积累。不多说,贴代码。 首先这个是我的代码,分制法: #include #include using namespace std;...

POJ 3087-Shuffle'm Up(模拟题)

I - Shuffle'm Up Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Su...

POJ 1068模拟题

Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24757   ...

poj 1281 MANAGER(简单模拟题)

MANAGER Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2504   Ac...

二分图简单模拟题 POJ 1274、1325、1469、2446

POJ 1274 POJ 1325 POJ 1469 POJ 2446

poj 3087 Shuffle'm Up(模拟题)

Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6143   A...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:POJ 1250 模拟题
举报原因:
原因补充:

(最多只允许输入30个字)