Guest User

Untitled

a guest
Jan 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. ACM International Collegiate Programming Contest, Asia-Amritapuri Site, 2011
  2. Problem A: Numerology
  3. Numerology is a difficult branch of magic, involving converting words and names to numbers, and deriving mystical significance from them. Harry Potter, our hero, has never had a good head for maths, being more at home killing evil wizards or playing Quidditch, but his Divination teacher at Hogwarts school of witchcraft has assigned him a numerology project for the Progcon ceremony. She has given him two integers A and B, and has asked him to list all the numbers in the range [A...B] inclusive that contain no digit that occurs more than twice in it, in decimal representation. Harry could not figure out a magic spell to do this task, but you can perhaps help him with your 'compooter thingy' that Muggles* use.
  4. Input (STDIN):
  5. The first line contains the number of test cases T. Each of the next T lines contains two integers, A and B.
  6. Output (STDOUT):
  7. Output T lines, one for each case containing the required answer for the corresponding case.
  8. Constraints:
  9. 1 <= T <= 10000
  10. 1 <= A <= B <= 10^18
  11. Time limit: 4 seconds
  12. Sample Input:
  13. 3
  14. 100 120
  15. 1000 1000
  16. 123 456
  17. Sample Output:
  18. 20
  19. 0
  20. 331
  21. Explanation:
  22. For the first case, all numbers except 111 satisfy the condition.
  23.  
  24. *Muggles = non-magical people
Add Comment
Please, Sign In to add comment