ZOJ 3436 July Number(DFS)
题意 把一个数替换为这个数相邻数字差组成的数 知道这个数只剩一位数 若最后的一位数是7 则称原来的数为 July Number 给你一个区间 求这个区间中July Number的个数
从7开始DFS 位数多的数总能由位数小的数推出
1 | #include <bits/stdc++.h> |
July Number Time Limit:2 Seconds Memory Limit:65536 KB
The digital difference of a positive number is constituted by the difference between each two neighboring digits (with the leading zeros omitted). For example the digital difference of 1135 is 022 = 22. The repeated digital difference, or differential root, can be obtained by caculating the digital difference until a single-digit number is reached. A number whose differential root is 7 is also called July Number. Your job is to tell how many July Numbers are there lying in the given interval [a, b].
Input
There are multiple cases. Each case contains two integers a and b. 1 ≤ a ≤ b ≤ 109.
Output
One integer k, the number of July Numbers.
Sample Input
1 10
Sample Output
1
Author: HE, Ningxu
Contest: ZOJ Monthly, November 2010