| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 758 人关注过本帖
标题:[求助]英文版题目(字符串)
取消只看楼主 加入收藏
温柔一刀
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-7-14
收藏
 问题点数:0 回复次数:4 
[求助]英文版题目(字符串)

有趣的游戏
Description
A few kids are standing around an old tree playing a game. The tree is so huge that each kid can only see the kids close to him/her.

The game consists many 'turns'. At the beginning of each turn of the game, a piece of paper is given to a randomly chosen kid. This kid writes the letter "B" if he is a boy or the letter "G" if a girl. Then he chooses a direction to pass the paper (clockwise or counter-clockwise), and gives the paper to his neighbor in that direction. The kid getting the paper writes down his sex too, and gives the paper to his neighbor in the same direction. In this way, the paper goes through the kids one by one, until one kid stops passing the paper and announces the end of this turn.

For example, there are five kids around the tree, and their genders are shown in Figure-1. The paper first goes to Kid1, after writing a "B" he passes it to Kid2, and Kid2 to Kid3. After Kid3 writes down a "G", she ends up this turn, and we get the paper with a string "BBG".

After N turns, we get N pieces of paper with strings of "B"s and/or "G"s. One of the kids will get all these papers, and has to figure out at least how many kids are around the tree playing the game. It's known that there are at least two kids. Please write a program to help him.
Input
There are several test cases. Each case starts with a line containing an integer N, the number of papers (2 <= N <= 16). Each of the following N lines contains a string on a paper, which is a nonempty string of letter "B"s and/or "G"s. Each string has no more than 100 letters.

A test case of N = 0 indicates the end of input, and should not be processed.
Output
For each test case, output the least possible number of kids in a line.
Sample Input
3
BGGB
BGBGG
GGGBGB
2
BGGGBBBGG
GBBBG
0
Sample Output
9
6

搜索更多相关主题的帖子: 英文版 字符 
2006-07-14 20:22
温柔一刀
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-7-14
收藏
得分:0 
这个思想是知道的
在程序编写的时候做的太复杂了
所以四楼的
看看能不能写 一下看看
嘿嘿
算法不精啊
2006-07-16 16:00
温柔一刀
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-7-14
收藏
得分:0 

时间是越短越好

2006-07-16 16:01
温柔一刀
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-7-14
收藏
得分:0 
难道都没有高手啊
没有人会解题啊
晕死
2006-07-17 20:37
温柔一刀
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-7-14
收藏
得分:0 

真的没有高手

2006-07-18 17:49
快速回复:[求助]英文版题目(字符串)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021861 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved