UVA 575: Skew Binary

Jasonlin posted @ 2011年3月28日 23:08 in UVA with tags 数学 进制转换 , 2141 阅读

题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=7&problem=516&mosmsg=Submission+received+with+ID+8687739

题目大意:

      定义一个新的进制数,把这种新数转化为十进制数。

解题代码:

#include<iostream>
using namespace std;
int main(){
	string s;
	while(cin>>s&&s!="0"){
		int sum=0;
		int len=s.length();
		for(int i=0;i<len;i++)
				sum+=(s[i]-'0')*((1<<(len-i))-1);
		cout<<sum<<endl;
	}
}

扩展知识:http://en.wikipedia.org/wiki/Positional_notation

seo service london 说:
2024年1月14日 18:15

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter