UVA - 575 Skew Binary
2016-07-21 21:22
375 查看
UVA - 575 Skew Binary
题目大意: 按照题目要求输出即可
Sample Input
10120200000000000000000000000000000
10
1000000000000000000000000000000
11
100
11111000001110000101101102000
0
Sample Output
442147483646
3
2147483647
4
7
1041110737
解题思路:
#include <iostream> #include <cmath> #include <cstring> #include <cstdio> using namespace std; int main() { char s[100]; int sum; while (scanf("%s",s) != EOF && strcmp(s,"0") != 0) { int l = strlen(s); sum = 0; for (int i = 0; i < l; i++) { sum = sum + (s[i] - '0') * (pow (2, l - i) - 1); } printf("%d\n",sum); } return 0; }
相关文章推荐
- Android第三十九天
- 【慕课学习】《JavaScript深入浅出》——javascript数据类型
- org.w3c.dom中节点添加属性,没有一定的顺序,但是dom4j中添加的属性是有顺序的
- 训练之DP-数塔
- Kefa and Company
- Bulbs
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- PAT-B 1009. 说反话
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- Android DrawableAnimation逐帧动画加载多图(OOM的解决)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)
- 杂记:Atmel sama5d3 Bus Matrix (MATRIX)