2719

/*
	10 1
	20 2
	30 3
	50 14
	60 15
	70 16
	80 17
	90 18
	100 19
	200 38
	300 ...
*/
// include file
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>

#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>

#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <functional>

using namespace std;

// typedef
typedef __int64 LL;

// 
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)

#define Z(a,b) ((a)<<(b))
#define Y(a,b) ((a)>>(b))

const double eps = 1e-6;
const double INFf = 1e100;
const int INFi = 1000000000;
const LL INFll = (LL)1<<62;
const double Pi = acos(-1.0);

template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T TMAX(T x,T y)
{
	if(x>y) return x;
	return y;
}
template<class T> inline T TMIN(T x,T y)
{
	if(x<y) return x;
	return y;
}
template<class T> inline T MMAX(T x,T y,T z)
{
	return TMAX(TMAX(x,y),z);
}
template<class T> inline T MMIN(T x,T y,T z)
{
	return TMIN(TMIN(x,y),z);
}
template<class T> inline void SWAP(T &x,T &y)
{
	T t = x;
	x = y;
	y = t;
}


// code begin
int DP[10][10];
int N;
int main()
{	
	read;
	write;
	for(int i=0;i<=9;i++)
		DP[1][i] = i>=4?1:0;
	for(int i=2;i<=9;i++)
	{
		DP[i][1] = DP[i-1][9]+DP[i-1][1];
		for(int j=2;j<=9;)
		{
			if(j==4)
			{
				j++;
				DP[i][j] = DP[i][j-2]+(int)pow(10.0,i-1)+DP[i][1];
				j++;
			}
			else
			{
				DP[i][j] = DP[i][j-1]+DP[i][1];
				j++;
			}
		}
	}

	while(scanf("%d",&N)&&N)
	{
		int ans = 0,t=N;
		for(int i=1;;i++)
		{
			ans += DP[i][N%10];
			N/=10;
			if(N==0) break;
		}
		printf("%d: %d\n",t,t-ans);
	}
	return 0;
}
posted @ 2011-05-01 01:39  AC2012  阅读(272)  评论(0编辑  收藏  举报