首页 > 代码库 > UVA-575-水题-模拟

UVA-575-水题-模拟

题意:

按照这个公式模拟

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-水题-模拟