#include <iostream> #include <string> unsigned int A(short counter) { switch (counter) { case 1: return 2; break; case 2: return 12; break; case 3: return 40; break; case 4: return 176; break; case 5: return 544; break; case 6: return 1984; break; case 7: return 5760; break; case 8: return 19200; break; case 9: return 53760; break; case 10: return 171008; break; case 11: return 468992; break; case 12: return 1454080; break; case 13: return 3940352; break; case 14: return 12042240; break; case 15: return 32407552; break; case 16: return 98238464; break; case 17: return 263323648; break; case 18: return 794558464; break; case 19: return 2124939264; break; } return -1; } unsigned int B(short counter) { switch (counter) { case 1: return 1; break; case 2: return 1; break; case 3: return 10; break; case 4: return 28; break; case 5: return 152; break; case 6: return 432; break; case 7: return 1760; break; case 8: return 4800; break; case 9: return 17280; break; case 10: return 45824; break; case 11: return 155136; break; case 12: return 404480; break; case 13: return 1325056; break; case 14: return 3420160; break; case 15: return 11001856; break; case 16: return 28229632; break; case 17: return 89882624; break; case 18: return 229834752; break; case 19: return 727580672; break; } return -1; } int main() { std::cin.tie(NULL); std::cout.sync_with_stdio(0); unsigned long long int result = 1; const char* n; std::string temp; std::cin >> temp; n = temp.c_str(); short counter = 1; for (int i = 0; i < temp.length(); i++) { if (n[i] != '1') { result *= (A(counter) + B(counter) * (n[i] - '1')); counter = 0; } counter++; } if (counter != 1) result *= A(counter); std::cout << result; 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | #include <iostream> #include <string> unsigned int A(short counter) { switch (counter) { case 1: return 2; break; case 2: return 12; break; case 3: return 40; break; case 4: return 176; break; case 5: return 544; break; case 6: return 1984; break; case 7: return 5760; break; case 8: return 19200; break; case 9: return 53760; break; case 10: return 171008; break; case 11: return 468992; break; case 12: return 1454080; break; case 13: return 3940352; break; case 14: return 12042240; break; case 15: return 32407552; break; case 16: return 98238464; break; case 17: return 263323648; break; case 18: return 794558464; break; case 19: return 2124939264; break; } return -1; } unsigned int B(short counter) { switch (counter) { case 1: return 1; break; case 2: return 1; break; case 3: return 10; break; case 4: return 28; break; case 5: return 152; break; case 6: return 432; break; case 7: return 1760; break; case 8: return 4800; break; case 9: return 17280; break; case 10: return 45824; break; case 11: return 155136; break; case 12: return 404480; break; case 13: return 1325056; break; case 14: return 3420160; break; case 15: return 11001856; break; case 16: return 28229632; break; case 17: return 89882624; break; case 18: return 229834752; break; case 19: return 727580672; break; } return -1; } int main() { std::cin.tie(NULL); std::cout.sync_with_stdio(0); unsigned long long int result = 1; const char* n; std::string temp; std::cin >> temp; n = temp.c_str(); short counter = 1; for (int i = 0; i < temp.length(); i++) { if (n[i] != '1') { result *= (A(counter) + B(counter) * (n[i] - '1')); counter = 0; } counter++; } if (counter != 1) result *= A(counter); std::cout << result; return 0; } |