zoj 1712 Skew Binary

原创 2012年03月21日 12:04:47
#include "iostream"
#include "stdio.h"
#include "string.h"
using namespace std;

int main()
{
	char input[50];
	int num[50], len, i, ans, temp, tag;
	while (scanf("%s", input))
	{
		memset(num, 0, sizeof(num));
		ans = 0, temp = 2, tag = 1;
		if (strcmp(input, "0") == 0) break;
		len = strlen(input);
		for (i = 0; i < len; i++)
			num[len-i-1] = input[i] - 48;
		for (i = 0; i < len; i++)
		{
			ans += num[i] * (temp - 1);
			temp *= 2;
			if (ans > 2147483647)
			{
				cout << 2147483647 << endl;
				tag = 0;
				break;
			}
		}
		if (tag)
			cout << ans << endl;
	}
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

UVa 575 / ZOJ 1712 / Mid-Central USA 1997 Skew Binary (water ver.&斜二进制)

575 - Skew Binary Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlineju...

UVA 575-Skew Binary

A - Skew Binary Time Limit:3000MS    Memory Limit:0KB    64bit IO Format:%lld & %llu SubmitStatusP...

uva 575 - Skew Binary

Skew Binary  When a number is expressed in decimal, the k-th digit represents a multiple of 10k. (D...

UVa 575 Skew Binary

Skew Binary  When a number is expressed in decimal, the k-th digit represents a multiple ...

数论uva575-Skew Binary

Skew Binary  When a number is expressed in decimal, the k-th digit represents a multipl...

UVA575 Skew Binary

A - Skew Binary Time Limit:3000MS    Memory Limit:0KB    64bit IO Format:%lld & %llu SubmitStatu...

UVA - 575 Skew Binary

When a number is expressed in decimal, the k-th digit represents a multiple of 10k. (Digits are num...

uva 575 Skew Binary(数论)

uva 575 Skew Binary When a number is expressed in decimal, the k-th digit represents a multip...

UVA - 575 - Skew Binary (简单数论!)

UVA - 575 Skew Binary Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: ...

寒假集训.Skew Binary

Skew Binary Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)