编程介的小学生 2017-04-01 02:28 采纳率: 20.5%
浏览 795
已采纳

Watashi and Kimi

In the year of 2010, "Watashi" and "Kimi" become the admins of ZOJ. They are twins, but "Kimi" always does the right things while "Watashi" always does the wrong things.

The online contest "ZOJ Weekly" is scheduled in tomorrow. There will be N problems in this contest, and "Watashi" and "Kimi" are busy checking the the data for all the problems. After "Kimi" checks the data of a problem, the data will always be right, but After "Watashi" checks the data of a problem, the data will always be wrong!

In each turn when "Watashi" or "Kimi" checks, he will first choose a problem to check. Either of them will never choose the problems which he can make sure is most recently checked by himself (not by the other one). He will then randomly choose a problem in the candidate problems, and checks the data for that problem. So when either of them is sure that all the problems are lately checked by himself, he will do nothing.

Given the order in which they check the problems, you are to print the probability that all the data are right after all the checks made by them.

Initially, all the problems have been checked by "Kimi" so all of them are right at first. And both of them know when the other one checks the data, but they can't see which problem the other one is checking.

Input

There are multiple test cases. There are two parts for each case. The first part is one line with an integer N (1 <= N <= 16), the number of problems for the contest. The second part consists with some lines. A line will be either "Watashi" or "Kimi", which means a check made by "Watashi" or a check made by "Kimi". This part ends with a line with "End". There will be at most 100 lines for the second part.

Output

For each case, print a real number in one line, the probability that all the data are right after all the checks made by them. Keep two digits after the decimal point.

Sample Input

2
Watashi
End
3
Watashi
Kimi
End
Sample Output

0.00
0.33

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-04-10 15:49
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。