#include <cstdio> #include <cstdint> #include <vector> int main () { std::vector<char> digits; char c; while (1) { scanf("%c", &c); if (c < '0' || c > '9') { break; } digits.insert(digits.begin(), c); } std::vector<uint64_t> sums; sums.push_back(1); for(int i = 0; i < digits.size(); ++i) { uint64_t next = (uint64_t)(1 + digits[i] - '0') * sums[sums.size() - 1]; if (digits[i] == '1' && i > 0) { next += sums[sums.size() - 2] * (uint64_t)('9' - digits[i - 1]); } sums.push_back(next); } printf("%lld\n", sums[sums.size() - 1]); 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 | #include <cstdio> #include <cstdint> #include <vector> int main () { std::vector<char> digits; char c; while (1) { scanf("%c", &c); if (c < '0' || c > '9') { break; } digits.insert(digits.begin(), c); } std::vector<uint64_t> sums; sums.push_back(1); for(int i = 0; i < digits.size(); ++i) { uint64_t next = (uint64_t)(1 + digits[i] - '0') * sums[sums.size() - 1]; if (digits[i] == '1' && i > 0) { next += sums[sums.size() - 2] * (uint64_t)('9' - digits[i - 1]); } sums.push_back(next); } printf("%lld\n", sums[sums.size() - 1]); return 0; } |