A1098 | [COCI-2006_2007-regional]#2 CIRCLE
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
One nice summer day while Mirko was drinking lemonade in his room...
"Big brother!", yells Stanko.
"I wonder sometimes which of the two of us is the big one. What is it?", Mirko asked.
"Listen carefully! In the backyard I have N pebbles arranged in a circle. Some of the pebbles are black, some are white. I will do the following: between any two neighbouring pebbles of the same colour I will insert a black pebble, and between any two neighbouring pebbles of different colours I will insert a white pebble. At that point there will be 2N pebbles in the circle, so I will remove the starting N pebbles so that only the newly added N pebbles remain. And all this I intend to do exactly K times.
And then you are to determine my starting circle.", said Stanko long-windedly.
"Ha! I shall not fall prey to your trickery! I can see that it is not necessarily possible to know exactly what the starting circle was, but I can count the number of distinct starting circles that give the same result as your circle after exactly K of those weird transformations of yours", answered Mirko.
You are given the configuration of the circle before Stanko performed the transformation described above K times.
Write a program that determines the number of distinct starting circles that give the same circle after K transformations as Stanko's original circle does after K transformations.
Two configurations of pebbles are considered to be the same circle if one can be gotten from the other by rotating it any number of positions. For example BBW and BWB is the same circle whereas BBWWBW and WWBBWB are not.
"Big brother!", yells Stanko.
"I wonder sometimes which of the two of us is the big one. What is it?", Mirko asked.
"Listen carefully! In the backyard I have N pebbles arranged in a circle. Some of the pebbles are black, some are white. I will do the following: between any two neighbouring pebbles of the same colour I will insert a black pebble, and between any two neighbouring pebbles of different colours I will insert a white pebble. At that point there will be 2N pebbles in the circle, so I will remove the starting N pebbles so that only the newly added N pebbles remain. And all this I intend to do exactly K times.
And then you are to determine my starting circle.", said Stanko long-windedly.
"Ha! I shall not fall prey to your trickery! I can see that it is not necessarily possible to know exactly what the starting circle was, but I can count the number of distinct starting circles that give the same result as your circle after exactly K of those weird transformations of yours", answered Mirko.
You are given the configuration of the circle before Stanko performed the transformation described above K times.
Write a program that determines the number of distinct starting circles that give the same circle after K transformations as Stanko's original circle does after K transformations.
Two configurations of pebbles are considered to be the same circle if one can be gotten from the other by rotating it any number of positions. For example BBW and BWB is the same circle whereas BBWWBW and WWBBWB are not.
输入格式
The first line of input contains two integers N and K, 3 ≤ N ≤ 100, 1 ≤ K ≤ 10, where N is the number of pebbles in the circle and K is the number of transformations made by Stanko.
The second line contains exactly N characters 'B' or 'W' representing Stanko's original circle.
The second line contains exactly N characters 'B' or 'W' representing Stanko's original circle.
输出格式
Output the number of possible distinct starting circles on a single line.
输入输出样例
输入 #1
3 1 BBW
输出 #1
2
输入 #2
6 2 WBWWBW
输出 #2
3
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted