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 10801 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 [1100] 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, 1mn32000. The output from your program is the number of rotatable numbers in the interval.

You may assume that all input is valid.

Sample Input

Copy
1
100

Sample Output

Copy
6

Comments


  • 0
    701030474  commented 36 days ago 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).


  • -30
    lechengzhang  commented 92 days ago

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