#include <bits/stdc++.h> using namespace std; int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; vector<int> digits; while (n) { digits.push_back(n % 10); n /= 10; } int m = digits.size(); vector<long long> dp(m + 1); dp[0] = 1; for (int i = 0; i < m; ++i) { dp[i + 1] += dp[i] * (digits[i] + 1); if (i < m - 1 && digits[i + 1] == 1) { dp[i + 2] += dp[i] * (9 - digits[i]); } } cout << dp[m] << "\n"; return 0; }
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 | #include <bits/stdc++.h> using namespace std; int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; vector<int> digits; while (n) { digits.push_back(n % 10); n /= 10; } int m = digits.size(); vector<long long> dp(m + 1); dp[0] = 1; for (int i = 0; i < m; ++i) { dp[i + 1] += dp[i] * (digits[i] + 1); if (i < m - 1 && digits[i + 1] == 1) { dp[i + 2] += dp[i] * (9 - digits[i]); } } cout << dp[m] << "\n"; return 0; } |