1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

unsigned long long f_one(unsigned long long len_one){
	if(len_one==-1){
		return 0;
	}else if(len_one%2==0){
		return (pow(2,len_one)*(pow(2,len_one+1)+1))/3;
	}else{
		return (pow(2,len_one)*(pow(2,len_one+1)-1))/3;
	}
}

int main(){
	
	unsigned long long  n;
	cin >> n;
	
	if(n==0){
		cout << 1;
	}else{
		vector<pair<unsigned long long,int> >serie;
		
		unsigned long long max_len_one = 0;
		unsigned long long len_one = 0;
		int digit_to_ad = -1;
		
		while(n>0){
			int digit = n%10;
			if(digit!=1 or  digit==n ){
				if(digit==1){
					len_one++;
				}
				
				serie.push_back(make_pair(len_one,digit_to_ad));
				
				if(len_one>max_len_one){
					max_len_one = len_one;
				}
				
				len_one=0;
				digit_to_ad = digit;
				
				if(digit==n and digit!=1){
					serie.push_back(make_pair(len_one,digit_to_ad));
				}
			}else{
				len_one++;
			}
			n/=10;
		}
		
		unsigned long long sum_one=0;
		unsigned long long sum=1;
		
		//cout<< serie[0].first << " " << serie[0].second << endl;
		sum_one+=f_one(serie[0].first);
		
		for(unsigned long long i=1; i<serie.size(); i++){
			//cout<< serie[i].first << " " << serie[i].second << endl;
			sum*=((serie[i].second+1)*f_one(serie[i].first)+((9-serie[i].second)*f_one(serie[i].first-1)));
		}
		
		if(sum!=0 and sum_one!=0){
			sum*=sum_one;
		}
		cout.precision(0);
		cout<< fixed<<sum;
	}
}