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 #include using namespace std; long long rozbij(long long N, string s) { long long a = 0, b = 0; if(N > 0){ if(N % 100 <= 18 && N % 100 >= 10){ long long R = N; string s1 = ""; s1 += (char)(R % 10 + '0'); R /= 10; s1 = (char)(R % 10 + '0') + s1; s1 += s; s1 = '$' + s1; //cout << "S = " << R / 10 << " " << s1 << "\n"; a += rozbij(R / 10, s1); } string s2 = ""; s2 = '$'; s2 += (char)(N % 10 + '0'); s2 += s; //cout << "S = " << N / 10 << " " << s2 << "\n"; b += rozbij(N / 10, s2); } else{ //cout << "Last stage " << s << "\n"; long long wynik = 1; for(int i = s.size() - 1; i > 0; i--){ int x = s[i] - '0'; if(s[i - 1] != '\$'){ x += 10 * ((int)(s[i - 1] - '0')); i--; } i--; if(x < 10) wynik *= x + 1; else wynik *= 19 - x; } //cout << "wynik = " << wynik << "\n";; return wynik; } return a + b; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long N; cin >> N; cout << rozbij(N, "") << "\n"; }