#include <iostream>
using namespace std;
char tab[256];
unsigned long long c[32];
unsigned long long w[32];
int main() {
// your code goes here
scanf("%s",tab);
// printf("%s\n",tab)
int i = 0;
for(;tab[i];)
{
c[i] = tab[i] - '0';
w[i] = 0;
i++;
}
int l = i;
c[i] = 9;
w[i] = 1;
w[i+1] = 0;
while(i--)
{
w[i] = (c[i] + 1)*w[i+1];
if(c[i]==1)
{
w[i]+=(9-c[i+1])*w[i+2];
}
}
printf("%llu",w[0]);
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 30 31 32 33 34 35 36 | #include <iostream> using namespace std; char tab[256]; unsigned long long c[32]; unsigned long long w[32]; int main() { // your code goes here scanf("%s",tab); // printf("%s\n",tab) int i = 0; for(;tab[i];) { c[i] = tab[i] - '0'; w[i] = 0; i++; } int l = i; c[i] = 9; w[i] = 1; w[i+1] = 0; while(i--) { w[i] = (c[i] + 1)*w[i+1]; if(c[i]==1) { w[i]+=(9-c[i+1])*w[i+2]; } } printf("%llu",w[0]); return 0; } |
English