首页 > 其他 > 详细

UVA-575-水题-模拟

时间:2017-05-14 17:48:55      阅读:371      评论:0      收藏:0      [点我收藏+]

题意:

按照这个公式模拟

10120skew = 1×(25 1)+0×(24 1)+1×(23 1)+2×(22 1)+0×(21 1) = 31+0+7+6+0 = 44.

#include<iostream>
#include <stdio.h>
#include <memory.h>
#include<queue>
#include<math.h>
using namespace std;

int main()
{
	freopen("d:\\1.txt", "r", stdin);
	string str;
	while (cin >> str)
	{
		int length = str.length();
		if(length == 1 && str[0] == ‘0‘)
			return 0;
		int total = 0;
		for(int i = length - 1; i >= 0; i--)
		{
			total += (str.at(i) - ‘0‘) * (pow(2, length - i) - 1);
		}
		cout<<total<<endl;
	}
	return 0;
}

  

UVA-575-水题-模拟

原文:http://www.cnblogs.com/shuiyonglewodezzzzz/p/6852909.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!