Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int how(int x) {
- switch(x) {
- case 1:
- return 1;
- case 2:
- return 1;
- case 3:
- return 1;
- case 4:
- return 2;
- case 5:
- return 2;
- case 6:
- return 3;
- case 7:
- return 4;
- case 8:
- return 4;
- case 9:
- return 5;
- case 0:
- return 1;
- }
- return 0;
- }
- int main() {
- int k;
- unsigned long long int n;
- vector <int> a;
- cin >> k;
- for (int i = 0; i < k; ++i) {
- a.clear();
- cin >> n;
- unsigned long long ans = 0;
- if (n < 10) {
- cout << how(n) << endl;
- continue;
- }
- while (n > 0) {
- a.push_back(n % 10);
- n /= 10;
- }
- unsigned long long f = 1;
- for (int j = 0; j < a.size() - 1; ++j)
- f *= how(a[j]);
- if ((a.back() == 1) || (a.back() == 2) || (a.back() == 3) || (a.back() == 5) || (a.back() == 8))
- f = 0;
- ans += f;
- a.back()--;
- f = how(a.back());
- for (int j = 0; j < a.size() - 1; ++j) {
- f *= 5;
- }
- ans += f;
- cout << ans << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement