Codeforces Round #272 (Div. 2) 476B - Dreamoon and WiFi Solution

 


Problem Link: https://codeforces.com/problemset/problem/476/B

Solve in C++:  

///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat  Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a,b;
    cin>>a>>b;
    int i,pa=0,pb=0,q=0,cn=0;
    for(i=0; i<a.size(); i++)
    {
        if(a[i]=='+')
            pa++;
         if(b[i]=='+')
            pb++;
         if(b[i]=='?')
            q++;
    }
    double v=1<<q;
    for(i=0; i<v; i++)
    {
        if(__builtin_popcount(i)+pb==pa)
            cn++;
    }
    cout<<fixed<<setprecision(9)<<(double)cn/v<<endl;
}






No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.