#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <utility>
using namespace std;
long long a[100], b[100];
int main() {
long long n, i = 0, w = 0;
scanf("%lld", &n);
while (n > 0) {
i++;
b[i] = n % 10;
n /= 10;
}
a[i] = b[i] + 1;
a[i + 1] = 1;
for (long long j = i - 1; j > 0; j--) {
a[j] = a[j + 1] * (b[j] + 1);
if ((b[j] + 10 * b[j + 1] > 9) && (b[j] + 10 * b[j + 1] < 19)) {
a[j] += a[j + 2] * (18 - b[j] - 10 * b[j + 1] + 1);
}
}
printf("%lld", a[1]);
//system("pause");
}
//5, 38, 54
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 | #include <cstdio> #include <iostream> #include <string> #include <vector> #include <stdlib.h> #include <time.h> #include <algorithm> #include <cmath> #include <fstream> #include <utility> using namespace std; long long a[100], b[100]; int main() { long long n, i = 0, w = 0; scanf("%lld", &n); while (n > 0) { i++; b[i] = n % 10; n /= 10; } a[i] = b[i] + 1; a[i + 1] = 1; for (long long j = i - 1; j > 0; j--) { a[j] = a[j + 1] * (b[j] + 1); if ((b[j] + 10 * b[j + 1] > 9) && (b[j] + 10 * b[j + 1] < 19)) { a[j] += a[j + 2] * (18 - b[j] - 10 * b[j + 1] + 1); } } printf("%lld", a[1]); //system("pause"); } //5, 38, 54 |
English