def solveExp(index,str_):
if(index>=len(str_)):
return 0
if(str_[index]=='+'):
return 1 + solveExp(index+1,str_)
else:
return -1+ solveExp(index+1,str_)
def solveMain(index,str_,target,ans,res,leng):
if(index>=len(str_)):
leng.append(True)
if(ans==target):
res.append(True)
return 0
if(str_[index]=='+'):
solveMain(index+1,str_,target,ans+1,res,leng)
elif(str_[index]=='-'):
solveMain(index+1,str_,target,ans-1,res,leng)
else:
solveMain(index+1,str_,target,ans+1,res,leng)
solveMain(index+1,str_,target,ans-1,res,leng)
s1=str(input())
s2=str(input())
k1 = solveExp(0,s1)
k2 = []
leng=[]
solveMain(0,s2,k1,0,k2,leng)
if('?' in s2):
op=format(len(k2)/len(leng), '.12f')
print(op)
else:
print(len(k2))
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
string s1,s2;
cin>>s1>>s2;
int ps1 = 0;
int ps2 = 0;
int empty = 0;
for(int i=0; i<s1.size(); i++)
{
if(s1[i] == '+')
{
ps1++;
}
if(s2[i] == '+')
{
ps2++;
}
if(s2[i] == '?')
{
empty++;
}
}
int counter = 0;
//cout<<"Empty = "<<empty<<" "<<"LEn = "<<(1<<empty)<<"\n";
for(int i=0; i< (1<<empty); i++)
{
//cout<<bitset<32>(i)<<"\n";
//cout<<__builtin_popcount(i) <<" "<<ps2<<" "<<ps1<<"\n";
if(__builtin_popcount(i) + ps2 == ps1)
{
counter++;
}
}
cout<<fixed<<setprecision(9)<<(double)counter/(1<<empty)<<endl;
return 0;
}
780C - Andryusha and Colored Balloons | 1153A - Serval and Bus |
1487C - Minimum Ties | 1136A - Nastya Is Reading a Book |
1353B - Two Arrays And Swaps | 1490E - Accidental Victory |
1335A - Candies and Two Sisters | 96B - Lucky Numbers (easy) |
1151B - Dima and a Bad XOR | 1435B - A New Technique |
1633A - Div 7 | 268A - Games |
1062B - Math | 1294C - Product of Three Numbers |
749A - Bachgold Problem | 1486B - Eastern Exhibition |
1363A - Odd Selection | 131B - Opposites Attract |
490C - Hacking Cypher | 158B - Taxi |
41C - Email address | 1373D - Maximum Sum on Even Positions |
1574C - Slay the Dragon | 621A - Wet Shark and Odd and Even |
1395A - Boboniu Likes to Color Balls | 1637C - Andrew and Stones |
1334B - Middle Class | 260C - Balls and Boxes |
1554A - Cherry | 11B - Jumping Jack |