2018.09.07 Amount of degrees(数位dp)】的更多相关文章

描述 求给定区间[X,Y]中满足下列条件的整数个数:这个数恰好等于K个互不相等的B的整数次幂之和. 例如,设X=15,Y=20,K=2,B=2,则有且仅有下列三个数满足题意: 17 = 24+20, 18 = 24+21, 20 = 24+22. 输入 第一行包含两个整数X和Y.接下来两行包含整数K和B. 输出 只包含一个整数,表示满足条件的数的个数. 样例输入 15 20 2 2 样例输出 3 提示 数据规模:1 ≤ X ≤ Y ≤ 2^31−1,1 ≤ K ≤ 20, 2 ≤ B ≤ 10…
题目大意 求给定区间[X,Y]中满足下列条件的整数个数:这个数恰好等于K个互不相等的B的整数次幂之和.例如,设X=15,Y=20,K=2,B=2,则有且仅有下列三个数满足题意: 输入:第一行包含两个整数X和Y.接下来两行包含整数K和B. 输出:只包含一个整数,表示满足条件的数的个数. 数据规模:1 ≤ X ≤ Y ≤ 2^31−1,1 ≤ K ≤ 20,  2 ≤ B ≤ 10. 题解 <浅谈数位类统计问题>的论问题~~~~~人生第一道数位DP,哈哈~~~O(∩_∩)O~~代码纯属抄袭~~~~…
Discription Create a code to determine the amount of integers, lying in the set [X; Y] and being a sum of exactly K different integer degrees of B. Example. Let X=15, Y=20, K=2, B=2. By this example 3 numbers are the sum of exactly two integer degree…
题目链接 我看错题了...都是泪啊,不存在3*4^2这种情况...系数必须为1... #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; #define LL long long ]; LL dp[][]; int k,b; LL dfs(int pos,int pre,int bound) { int i,end; L…
传送门 数位dp板子题. f[i][mod]" role="presentation" style="position: relative;">f[i][mod]f[i][mod]表示当前进行到第i位,所有数位数字之和的余数是mod" role="presentation" style="position: relative;">modmod时的种类数,根据当前位选择是否有限制转移就行了. 代码…
1057. Amount of Degrees Time limit: 1.0 second Memory limit: 64 MB Create a code to determine the amount of integers, lying in the set [X;Y] and being a sum of exactlyK different integer degrees of B. Example. Let X=15, Y=20, K=2, B=2. By this exampl…
#include<bits/stdc++.h>using namespace std;int num[20];//按位储存数字int mod;long long dp[20][110][110];//位数,位数和,位数和对mod取模的余数 long long dfs(int pos,int he,int yushu,int limit)//通常用三个以上变量dfs,分别用来表示状态,前导零,数字上限,这道题没有前导零,分别表示//数字的位数,前面位数和,对于mod的余数{    if(pos=…
传送门 斜率优化dp经典题. 令f[i]表示i这个地方修建仓库的最优值,那么答案就是f[n]. 用dis[i]表示i到1的距离,sump[i]表示1~i所有工厂的p之和,sum[i]表示1~i所有工厂的p*dis之和. 那么有状态转移方程: f[i]=min(f[j]+dis[i]∗(sump[i−1]−sump[j])−(sum[i]−sum[j])+c[i])" role="presentation" style="position: relative;&quo…
传送门 斜率优化dp经典题. 题目中说的很清楚,设f[i]表示前i个数分配出的最大值. 那么有: f[i]=max(f[j]+A∗(sum[i]−sum[j])2+B∗(sum[i]−sum[j])+C)" role="presentation" style="position: relative;">f[i]=max(f[j]+A∗(sum[i]−sum[j])2+B∗(sum[i]−sum[j])+C)f[i]=max(f[j]+A∗(sum[i…
传送门 斜率优化dp好题. 对于第i只猫,显然如果管理员想从出发开始刚好接到它,需要在t[i]=h[i]−dist(1,i)" role="presentation" style="position: relative;">t[i]=h[i]−dist(1,i)t[i]=h[i]−dist(1,i)的时候出发才行. 这样的话,如果把第l~r只猫分成一组,那么当前分组需要的最小花费是 t[r]−t[l]+t[r]−t[l+1]+t[r]−t[l+2]+…