汝佳哥把这道题归为数论。按照题中的计算步骤,直接模拟就过了。
#include <stdio.h>
#include <math.h>
#include <string.h>
int main() {
char str[50];
while (scanf("%s", str) && str[0]!='0') {
int len = strlen(str);
int res = 0;
for (int i=0; i<len; i++) {
int tmp = str[i] - '0';
res += tmp * ((int)(pow(2, len-i)+0.1) - 1);
}
printf("%d\n", res);
}
return 0;
}
本文介绍了如何将数学难题转化为代码实现,通过直接模拟的方法解决数论问题。使用C语言编写程序,通过字符串输入和数学运算,实现了高效的解题过程。
&spm=1001.2101.3001.5002&articleId=8545533&d=1&t=3&u=21bec41f169540efa17c23255aad40e8)
682

被折叠的 条评论
为什么被折叠?



