Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define ll long long
- int main() {
- ll n, m;
- cin >> m;
- for (int i = 0; i < m; ++i) {
- cin >> n;
- ll t = n;
- ll last = n;
- ll k = 0;
- while (t) {
- if (t/10==0) {
- last = t;
- }
- t /= 10;
- ++k;
- }
- ll ans = 5;
- ll tmp = 5;
- for (ll i = 2; i < k; ++i) {
- ans += 4*tmp;
- tmp *= 5;
- }
- if (k == 1) {
- if (n >= 0 && n <= 3) {
- ans = 1;
- } else if (n >= 4 && ans <= 5) {
- ans = 2;
- } else if (n == 6) {
- ans = 3;
- } else if (n >= 7 && n <= 8) {
- ans = 4;
- } else if (n == 9) {
- ans = 5;
- }
- } else if (last >= 4 && last <= 5) {
- ans += tmp;
- } else if (last == 6) {
- ans += 2*tmp;
- } else if (last >= 7 && last <= 8) {
- ans += 3*tmp;
- } else if (last == 9) {
- tmp += 4*tmp;
- }
- cout << ans << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement