题解 | #skew数#

skew数

https://www.nowcoder.com/practice/5928127cc6604129923346e955e75984

#include <stdio.h>
#include <math.h>
#include <string.h>

int main() {
    char a[32];
    int num,length;
    //scanf("%s",a);
    while(scanf("%s",a)!=EOF){
        num=0;
        length=strlen(a);
        for(int i=0;a[i]!='\0';i++){
            num+=(a[i]-'0')*(pow(2,(length-i))-1);
        }
        printf("%d\n",num);
      //  scanf("%s",a);
    }
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务