X mod f(x) (数位DP)

该博客讨论了如何在给定区间[A, B]内找到所有整数x,使得x除以f(x)的余数为0。其中f(x)表示x的各位数字之和。通过使用数位动态规划(DP)来解决这个问题,dp[pos][sum][x][mod]表示前pos位数字和为sum,且除以x余数为mod的状态。博主给出了转移方程并指出,需要枚举所有可能的数字和情况来求解。" 127210852,643027,OWT-SFU中RTP扩展头的处理解析,"['服务器开发', '实时通信', 'WebRTC']
摘要由CSDN通过智能技术生成
题目链接:https://cn.vjudge.net/problem/HDU-4389
Here is a function f(x):
   int f ( int x ) {
       if ( x == 0 ) return 0;
       return f ( x / 10 ) + x % 10;
   }


   Now, you want to know, in a given interval [A, B] (1 <= A <= B <= 10 9), how many integer x that mod f(x) equal to 0.

Input

   The first line has an integer T (1 <= T <= 50), indicate the number of test cases. 
   Each test case has two integers A, B. 

Output

   For each test case, output only one line containing the case number and an integer indicated the number of x. 

Sample Input

2
1 10
11 20

Sample Output

Case 1: 10
Case 2: 3

题意:

f(x)为x的各位数之和。

求[A,B]范围内x%f(x)==0的x的个数

 

用dp[pos][sum][x][mod]来表示 第pos位之前各位数字之和为sum的数 除以x(也就是题意中的f(x

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值