302471: CF476B. Dreamoon and WiFi

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Dreamoon and WiFi

题意翻译

Dreamoon站在位置$ 0 $,他想知道Wifi在哪儿,于是Drazil给他发了条短信告诉他怎么走,'+'代表向前走一个,'-'代表向后走一格。可是Dreamoon收到的短信中有错误或者未识别的字符,即'?'。Dreamoon如果遇到未识别的字符他就会等概率地向前或向后走一个,问他有多大的概率找到Wifi,答案误差不能超过$ 1e-9 $

题目描述

Dreamoon is standing at the position $ 0 $ on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon's smartphone and Dreamoon follows them. Each command is one of the following two types: 1. Go 1 unit towards the positive direction, denoted as '+' 2. Go 1 unit towards the negative direction, denoted as '-' But the Wi-Fi condition is so poor that Dreamoon's smartphone reports some of the commands can't be recognized and Dreamoon knows that some of them might even be wrong though successfully recognized. Dreamoon decides to follow every recognized command and toss a fair coin to decide those unrecognized ones (that means, he moves to the $ 1 $ unit to the negative or positive direction with the same probability $ 0.5 $ ). You are given an original list of commands sent by Drazil and list received by Dreamoon. What is the probability that Dreamoon ends in the position originally supposed to be final by Drazil's commands?

输入输出格式

输入格式


Dreamoon is standing at the position $ 0 $ on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon's smartphone and Dreamoon follows them. Each command is one of the following two types: 1. Go 1 unit towards the positive direction, denoted as '+' 2. Go 1 unit towards the negative direction, denoted as '-' But the Wi-Fi condition is so poor that Dreamoon's smartphone reports some of the commands can't be recognized and Dreamoon knows that some of them might even be wrong though successfully recognized. Dreamoon decides to follow every recognized command and toss a fair coin to decide those unrecognized ones (that means, he moves to the $ 1 $ unit to the negative or positive direction with the same probability $ 0.5 $ ). You are given an original list of commands sent by Drazil and list received by Dreamoon. What is the probability that Dreamoon ends in the position originally supposed to be final by Drazil's commands?

输出格式


Output a single real number corresponding to the probability. The answer will be considered correct if its relative or absolute error doesn't exceed $ 10^{-9} $ .

输入输出样例

输入样例 #1

++-+-
+-+-+

输出样例 #1

1.000000000000

输入样例 #2

+-+-
+-??

输出样例 #2

0.500000000000

输入样例 #3

+++
??-

输出样例 #3

0.000000000000

说明

Dreamoon is standing at the position $ 0 $ on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon's smartphone and Dreamoon follows them. Each command is one of the following two types: 1. Go 1 unit towards the positive direction, denoted as '+' 2. Go 1 unit towards the negative direction, denoted as '-' But the Wi-Fi condition is so poor that Dreamoon's smartphone reports some of the commands can't be recognized and Dreamoon knows that some of them might even be wrong though successfully recognized. Dreamoon decides to follow every recognized command and toss a fair coin to decide those unrecognized ones (that means, he moves to the $ 1 $ unit to the negative or positive direction with the same probability $ 0.5 $ ). You are given an original list of commands sent by Drazil and list received by Dreamoon. What is the probability that Dreamoon ends in the position originally supposed to be final by Drazil's commands?

Input

题意翻译

Dreamoon站在位置$ 0 $,他想知道Wifi在哪儿,于是Drazil给他发了条短信告诉他怎么走,'+'代表向前走一个,'-'代表向后走一格。可是Dreamoon收到的短信中有错误或者未识别的字符,即'?'。Dreamoon如果遇到未识别的字符他就会等概率地向前或向后走一个,问他有多大的概率找到Wifi,答案误差不能超过$ 1e-9 $

加入题单

上一题 下一题 算法标签: