#P07754. 加数

Description

给出一个正整数n(1<=n<=100000)。在n的右边加入n的一半,然后在新数的右边再加入n的一半的一半,一直进行,直到不能再加为止。

例如 n=37
37的一半为18(取整数)加到n的右边成为

3718 18的一半为9,加到新数的右边成为

37189 9的一半为4,加到新数的右边成为

371894 4的一半为2,加到新数的右边成为

3718942 2的一半为1,加到新数的右边成为

37189421 1的一半为0,加数结束,最后得到的数是一个8位的数

Input

整数n

Output

加数结束后新数的长度。

Samples

输入数据 1

37

Copy

输出数据 1

8

Copy

Limitation

1s, 1024KiB for each test case.

代码

#include<bits/stdc++.h>
using namespace std;
int ws(int a)
{
	int s=0;
	while(a){
		a/=10;
		s++;
	}
	return s;
}
int main()
{
	int n;
	cin>>n;
	int x=ws(n);
	while(n)
	{
		n/=2;
		x+=ws(n);
	}
	cout<<x;
	return 0;
}