Advertisement
webeseit

Untitled

Mar 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #define ll long long
  5.  
  6. int main() {
  7. ll n, m;
  8. cin >> m;
  9. for (int i = 0; i < m; ++i) {
  10. cin >> n;
  11. ll t = n;
  12. ll last = n;
  13. ll k = 0;
  14. while (t) {
  15. if (t/10==0) {
  16. last = t;
  17. }
  18. t /= 10;
  19. ++k;
  20. }
  21. ll ans = 5;
  22. ll tmp = 5;
  23. for (ll i = 2; i < k; ++i) {
  24. ans += 4*tmp;
  25. tmp *= 5;
  26. }
  27.  
  28. if (k == 1) {
  29. if (n >= 0 && n <= 3) {
  30. ans = 1;
  31. } else if (n >= 4 && ans <= 5) {
  32. ans = 2;
  33. } else if (n == 6) {
  34. ans = 3;
  35. } else if (n >= 7 && n <= 8) {
  36. ans = 4;
  37. } else if (n == 9) {
  38. ans = 5;
  39. }
  40. } else if (last >= 4 && last <= 5) {
  41. ans += tmp;
  42. } else if (last == 6) {
  43. ans += 2*tmp;
  44. } else if (last >= 7 && last <= 8) {
  45. ans += 3*tmp;
  46. } else if (last == 9) {
  47. tmp += 4*tmp;
  48. }
  49.  
  50. cout << ans << '\n';
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement