301139: CF212C. Cowboys
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Cowboys
题意翻译
问题描述 n个牛仔站立于一个环中,并且每个牛仔都用左轮手枪指着他旁边的人!每个牛仔指着他顺时针或者逆时针方向上的相邻的人。正如很多西部片那样,在这一刻,绳命是入刺的不可惜……对峙的场景每秒都在变化。每秒钟牛仔们都会分析局势,当一对相邻的牛仔发现他们正在互指的时候,就会转过身。一秒内每对这样的牛仔都会转身。所有的转身都同时在一瞬间发生。我们用字母来表示牛仔所指的方向。“A”表示顺时针方向,“B”表示逆时针方向。如此,一个仅含“A”“B”的字符串便用来表示这个由牛仔构成的环。这是由第一个指着顺时针方向的牛仔做出的记录。例如,牛仔环“ABBBABBBA”在一秒后会变成“BABBBABBA”;而牛仔环“BABBA”会变成“ABABB”。 这幅图说明了“BABBA”怎么变成“ABABB” 一秒过去了,现在用字符串s来表示牛仔们的排列。你的任务是求出一秒前有多少种可能的排列。如果某个排列中一个牛仔指向顺时针,而在另一个排列中他指向逆时针,那么这两个排列就是不同的。 输入格式 输入数据包括一个字符串s,它只含有“A”和“B”。 输出格式 输出你求出来的一秒前的可能排列数。 数据规模和约定 s的长度为3到100(包含3和100) 由 @落叶知秋声 提供翻译题目描述
A very tense moment: $ n $ cowboys stand in a circle and each one points his colt at a neighbor. Each cowboy can point the colt to the person who follows or precedes him in clockwise direction. Human life is worthless, just like in any real western. The picture changes each second! Every second the cowboys analyse the situation and, if a pair of cowboys realize that they aim at each other, they turn around. In a second all such pairs of neighboring cowboys aiming at each other turn around. All actions happen instantaneously and simultaneously in a second. We'll use character "A" to denote a cowboy who aims at his neighbour in the clockwise direction, and character "B" for a cowboy who aims at his neighbour in the counter clockwise direction. Then a string of letters "A" and "B" will denote the circle of cowboys, the record is made from the first of them in a clockwise direction. For example, a circle that looks like "ABBBABBBA" after a second transforms into "BABBBABBA" and a circle that looks like "BABBA" transforms into "ABABB". ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF212C/8008a8372d251058ec538068ab582d52690a65b8.png) This picture illustrates how the circle "BABBA" transforms into "ABABB" A second passed and now the cowboys' position is described by string $ s $ . Your task is to determine the number of possible states that lead to $ s $ in a second. Two states are considered distinct if there is a cowboy who aims at his clockwise neighbor in one state and at his counter clockwise neighbor in the other state.输入输出格式
输入格式
The input data consists of a single string $ s $ . Its length is from 3 to 100 characters, inclusive. Line $ s $ consists of letters "A" and "B".
输出格式
Print the sought number of states.
输入输出样例
输入样例 #1
BABBBABBA
输出样例 #1
2
输入样例 #2
ABABB
输出样例 #2
2
输入样例 #3
ABABAB
输出样例 #3
4