Advertisement
webeseit

Untitled

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