您的位置:首页 > 其它

HDU 5787 K-wolf Number (数位DP)

2016-08-03 16:00 399 查看

K-wolf Number

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=5787

Description

Alice thinks an integer x is a K-wolf number, if every K adjacent digits in decimal representation of x is pairwised different.

Given (L,R,K), please count how many K-wolf numbers in range of [L,R].

Input

The input contains multiple test cases. There are about 10 test cases.

Each test case contains three integers L, R and K.

1≤L≤R≤1e18

2≤K≤5

Output

For each test case output a line contains an integer.

Sample Input

1 1 2

20 100 5

Sample Output

1

72

Source

2016 Multi-University Training Contest 5

题意:

找出区间[L,R]中有多少个数满足任意相邻的K位均不不相同.

题解:

数位DP:分别对l-1.r求出从0开始一共有多少个数满足条件.

dp[i][j]:处理到还剩下i个数时左边相邻k个数是j(j代表一串数)的情况种数.

用map
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: