题解 | #skew数#

skew数

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

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define len 2000

int chartoint(char c){
    int a = c-'0';
    if(a>=0&&a<=9){
        return a;
    }
    return -1;
}

int main(){
    char str[len];
    while(scanf("%s",str)!=EOF){
        int n = strlen(str);
        int res = 0;
        for(int i = 0;i<n;i++){
            res+=chartoint(str[i])*(pow(2,n-i)-1);
        }
        printf("%d\n",res);
    }
}

全部评论

相关推荐

08-25 14:25
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务