Statistics

Problem Statement for "TheAlmostLuckyNumbers"

Problem Statement

A lucky number is a number whose decimal representation contains only the digits 4 and 7. An almost lucky number is a number that is divisible by a lucky number. For example, 14, 36 and 747 are almost lucky, but 2 and 17 are not. Note that a number can be both lucky and almost lucky at the same time (for example, 747).

You are given longs a and b. Return the number of almost lucky numbers between a and b, inclusive.

Definition

Class:
TheAlmostLuckyNumbers
Method:
count
Parameters:
long, long
Returns:
long
Method signature:
long count(long a, long b)
(be sure your method is public)

Constraints

  • a will be between 1 and 10,000,000,000, inclusive.
  • b will be between a and 10,000,000,000, inclusive.

Examples

  1. 1

    10

    Returns: 3

    There are three almost lucky numbers less than or equal to ten - 4, 7 and 8.

  2. 14

    14

    Returns: 1

    14 is an almost lucky number.

  3. 1

    100

    Returns: 39

  4. 1234

    4321

    Returns: 1178

  5. 1

    3

    Returns: 0

  6. 1

    10000000000

    Returns: 3823045312

  7. 123456789

    987654321

    Returns: 330386840

  8. 1

    1

    Returns: 0

  9. 1000000000

    1000000000

    Returns: 1

  10. 4

    4

    Returns: 1

  11. 2

    2

    Returns: 0

  12. 3

    3

    Returns: 0

  13. 999970000

    999999999

    Returns: 11462

  14. 44

    77

    Returns: 15

  15. 48

    73

    Returns: 10

  16. 757148

    167851001

    Returns: 63880759

  17. 301413357

    336971125

    Returns: 13593801

  18. 160567226

    659598369

    Returns: 190781558

  19. 4890852

    391749388

    Returns: 147897472

  20. 26239573

    35766291

    Returns: 3642006

  21. 597007

    473038165

    Returns: 180616328

  22. 3615545

    326051437

    Returns: 123268713

  23. 118341523

    392289611

    Returns: 104731438

  24. 37215529

    170427799

    Returns: 50927765

  25. 168544291

    675016434

    Returns: 193626376

  26. 683447134

    950090227

    Returns: 101939155

  27. 82426873

    116752252

    Returns: 13122652

  28. 194041605

    706221269

    Returns: 195808401

  29. 69909135

    257655784

    Returns: 71776471

  30. 21417563

    84970744

    Returns: 24296649

  31. 4735993214

    5788109700

    Returns: 402228932

  32. 3788115833

    8956428880

    Returns: 1975870108

  33. 1662213698

    6214162788

    Returns: 1740230313

  34. 3951218642

    6331312118

    Returns: 909920679

  35. 1543831757

    5048844734

    Returns: 1339982138

  36. 1284888887

    5105102205

    Returns: 1460485012

  37. 4565962192

    7762163387

    Returns: 1221922073

  38. 8735993214

    9788109700

    Returns: 402229076

  39. 8788115833

    9956428880

    Returns: 446651414

  40. 8662213698

    9214162788

    Returns: 211012663

  41. 8951218642

    9331312118

    Returns: 145311415

  42. 8543831757

    9048844734

    Returns: 193068806

  43. 8284888887

    9105102205

    Returns: 313571473

  44. 8565962192

    9762163387

    Returns: 457313225

  45. 5000000000

    10000000000

    Returns: 1911522647

  46. 9000000000

    10000000000

    Returns: 382304516

  47. 4444444444

    7777777777

    Returns: 1274348603

  48. 999

    10000000000

    Returns: 3823044930

  49. 1000000000

    10000000000

    Returns: 3440740760

  50. 3

    1234567891

    Returns: 471980733

  51. 123

    9991999997

    Returns: 3819986852

  52. 9999

    10000000000

    Returns: 3823041489

  53. 5

    10000000000

    Returns: 3823045311

  54. 9999999999

    10000000000

    Returns: 1

  55. 2341243

    10000000000

    Returns: 3822150237

  56. 5

    9987654321

    Returns: 3818325523

  57. 515151515

    10000000000

    Returns: 3626100495

  58. 1

    1000000000

    Returns: 382304553

  59. 4745

    4474745457

    Returns: 1710713382

  60. 100

    10000000000

    Returns: 3823045274

  61. 1234567890

    9876543210

    Returns: 3303866595


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: