Created
February 7, 2017 16:55
-
-
Save KhaledElshamy/27f640954de2a6c94549dafccb941f42 to your computer and use it in GitHub Desktop.
B. Dreamoon and WiFi-Codeforces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // working.cpp by Bill Weinman <http://bw.org/> | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| int main() | |
| { | |
| string s1,s2; | |
| cin>>s1>>s2; | |
| int count=0,count1=0,count2=0,count3,count5,count6=0; | |
| for(int i=0;i<s1.size();i++) | |
| { | |
| if(s1[i]=='+') | |
| count1++; | |
| else | |
| count1--; | |
| } | |
| for(int i=0;i<s2.size();i++) | |
| { | |
| if(s2[i]=='?') | |
| count++; | |
| else if(s2[i]=='+') | |
| count2++; | |
| else | |
| count2--; | |
| } | |
| int x=pow(2,count); | |
| int y; | |
| for(int i=0;i<x;i++) | |
| { | |
| count3=0; | |
| if(i==0) | |
| count5=(count)*(-1); | |
| else | |
| { | |
| int l=i; | |
| while(l) | |
| { | |
| y=l%2; | |
| if(y==1) | |
| count3++; | |
| l/=2; | |
| } | |
| } | |
| count5=((count-count3)*(-1))+count3; | |
| if((count2+count5)==count1) | |
| count6++; | |
| } | |
| printf("%.12f",(float)count6/x); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment