当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3872:K-equivalence

题目描述
Consider a set K of positive integers.
Let p and q be two non-zero decimal digits. Call them K-equivalent if the following condition applies:


For every n __poj_jax_start__\in__poj_jax_end__\in K, if you replace one digit p with q or one digit q with p in the decimal notation of n then the resulting number will be an element of K.


For example, when K is the set of integers divisible by 3, the digits 1, 4, and 7 are K-equivalent. Indeed, replacing a 1 with a 4 in the decimal notation of a number never changes its divisibility by 3.
It can be seen that K-equivalence is an equivalence relation (it is reflexive, symmetric and transitive).
You are given a finite set K in form of a union of disjoint finite intervals of positive integers.
Your task is to find the equivalence classes of digits 1 to 9.
输入解释
The first line contains n, the number of intervals composing the set K (1 <= n <= 10 000).
Each of the next n lines contains two positive integers ai and bi that describe the interval [ai, bi] (i. e. the set of positive integers between ai and bi, inclusive), where 1 <= ai <= bi <= 1018. Also, for i __poj_jax_start__\in__poj_jax_end__\in [2..n]: ai >= b(i-1) + 2.
输出解释
Represent each equivalence class as a concatenation of its elements, in ascending order.
Output all the equivalence classes of digits 1 to 9, one at a line, sorted lexicographically.
输入样例
Sample Input #1:
1
1 566

Sample Input #2:
1
30 75
输出样例
Sample Output #1:
1234
5
6
789

Sample Output #2:
12
345
6
7
89

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3872

最后修改于 2020-10-29T07:14:11+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536