【leetcode】速算机器人

 

int calculate(char* s){
    int x=1,y=0,i;
    for (i=0; i<strlen(s); i++)
    {
        if (s[i]=='A')
            x=x*2+y;
        else
            y=y*2+x;
    }
    return x+y;
}

 

posted @ 2020-11-06 15:46  温暖了寂寞  阅读(96)  评论(0编辑  收藏  举报