CCC '00 J2 - 9966

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 1.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2000 Stage 1, Junior #2

The digits 0, 1, and 8 look much the same if rotated 180 degrees on the page (turned upside down). Also, the digit 6 looks much like a 9, and vice versa, when rotated 180 degrees on the page. A multi-digit number may also look like itself when rotated on the page; for example 9966 and 10\,801 do, but 999 and 1234 do not.

You are to write a program to count how many numbers from a given interval look like themselves when rotated 180 degrees on the page. For example, in the interval [1 \dots 100] there are six: 1, 8, 11, 69, 88, and 96.

Your program should take as input two integers, m and n, which define the interval to be checked, 1 \le m \le n \le 32\,000. The output from your program is the number of rotatable numbers in the interval.

You may assume that all input is valid.

Sample Input

1
100

Sample Output

6

Comments


  • 1
    701030474  commented on Feb. 16, 2025, 1:26 a.m. edited

    this one is a bit tricky, but its not too complicated if you have done an ambigram before. you really want to focus on reversing the numbers(list) and then configureing the 6's and 9's so that you will reverse its positions by looping (for loop would be easiest).


  • -33
    lechengzhang  commented on Dec. 21, 2024, 2:54 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 0
      24k_zilxh  commented on Feb. 13, 2025, 2:24 a.m.

      man stfu


    • 18
      ev_code  commented on Jan. 1, 2025, 4:58 p.m.

      Says the one who didn't even solve it yet.

      (Please don't just say things are "easy" for no reason, it may make others feel bad)