Codeforces Round #233 (Div. 2) B. Red and Blue Balls

OpenSoucre發表於2014-03-13
#include <iostream>
#include <string>

using namespace std;

int main(){
    int n;
    cin >> n;
    string str;
    cin >> str;
    long long cnt = 0, x = 1;
    for(int i = 0 ; i < n ; ++ i){
        if(str[i] == 'B') cnt+=(x << i);
    }
    cout<<cnt<<endl;
}

 

Codeforces Round #233 (Div. 2)

相關文章