Type: Default 1000ms 256MiB

产生数

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Background

给出一个整数 n(n<=2000)和 k 个变换规则(k≤15)。规则: ① 1个数字可以变换成另 1 个数字; ② 规则中,右边的数字不能为零。 例如:n=234,k=2 规则为 2 → 5 3 → 6 上面的整数 234 经过变换后可能产生出的整数为(包括原数)234,534,264,564 共 4 种不同的产生数。 求经过任意次的变换(0 次或多次),能产生出多少个不同的整数。仅要求输出不同整 数个数。

Format

Input

n k x1 y1 x2 y2 … … xn yn

Output

格式为一个整数(满足条件的整数个数)

Samples

234 
2 
2 5 
3 6 
4

Limitation

1s, 1024KB for each test case.

数据结构-栈与队列 树

Not Claimed
Status
Done
Problem
6
Open Since
2025-5-22 0:00
Deadline
2025-6-13 23:59
Extension
24 hour(s)