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

#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)
posted @ 2014-03-13 21:12  OpenSoucre  阅读(160)  评论(0编辑  收藏  举报