POJ 1565 Skew Binary pow函数使用
2010-11-30 22:24
471 查看
这题是水题,主要是用到了C++字符串和cmath中的pow函数。
最近课程有点多,做POJ时间不够,还是要抓紧一些,尤其是动态规划、搜索题等要多练。
最近课程有点多,做POJ时间不够,还是要抓紧一些,尤其是动态规划、搜索题等要多练。
#include <iostream> #include <string> #include <cmath> using namespace std; int main(){ string s; while(1){ cin>>s; if (s == "0") break; long result = 0; int k = 1; string::iterator it; for (it = s.end()-1;it!=s.begin();it--) { result += (*it - '0')*(pow(double(2),k++) - 1); } result += (*it - '0')*(pow(double(2),k) - 1); cout<<result<<endl; } return 0; }
相关文章推荐
- POJ 1565 Skew Binary pow函数使用
- POJ 1565 Skew Binary(简单的问题)
- POJ 1565:Skew Binary
- POJ 1565:Skew Binary
- poj 1565 Skew Binary
- poj 1565 Skew Binary二进制转换
- POJ 1565 Skew数
- poj 1565 Skew Binary
- POJ 1565 Skew Binary(简单题)
- OpenJudge / Poj 1565 Skew Binary C++
- poj1565---(数论)skew binary
- POJ 百炼 保研机试 2973:Skew数
- POJ 3013 SPFA算法,邻接表的使用
- poj 2769 Reduced ID Numbers(memset使用技巧)
- POJ 2777(线段树,区间更新,使用二进制染色问题)
- poj 2837 Silver Matrix 不使用栈的深搜
- 使用VS调试高效修改代码(poj 3984为例)
- 中国剩余定理的使用POJ
- poj 2049 Finding Nemo (反过来使用bfs)