ural1057 Amount of Degrees
这题有一点小坑点 就是AX^B A只能为0或者1 ,剩下的就比较好做的了。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
LL dp[][][];
int d[];
LL dfs(int i,int e,int k,int b)
{
if(i==-)
return k==;
if(!e&&dp[i][k][b] != -) return dp[i][k][b];
int mk = e?d[i]:;
int ans = ;
mk = min(,mk);
for(int j = ;j <= mk ;j++)
{
if(k-j>=)
{
ans+=dfs(i-,e&&j==d[i],k-j,b);
}
}
return e?ans:dp[i][k][b] = ans;
}
LL cal(int x,int k,int b)
{
int g = ;
while(x)
{
d[g++] = x%b;
x/=b;
}
return dfs(g-,,k,b);
}
int main()
{
int x,y,k,b;
memset(dp,-,sizeof(dp));
while(cin>>x>>y)
{
cin>>k>>b;
cout<<cal(y,k,b)-cal(x-,k,b)<<endl;
}
return ;
}
ural1057 Amount of Degrees的更多相关文章
- [ural1057][Amount of Degrees] (数位dp+进制模型)
Discription Create a code to determine the amount of integers, lying in the set [X; Y] and being a s ...
- Ural1057. Amount of Degrees 题解 数位DP
题目链接: (请自行百度进Ural然后查看题号为1057的那道题目囧~) 题目大意: Create a code to determine the amount of integers, lying ...
- URAL1057. Amount of Degrees(DP)
1057 简单的数位DP 刚开始全以2进制来算的 后来发现要找最接近x,y值的那个基于b进制的0,1组合 #include <iostream> #include<cstdio&g ...
- Ural1057 - Amount of Degrees(数位DP)
题目大意 求给定区间[X,Y]中满足下列条件的整数个数:这个数恰好等于K个互不相等的B的整数次幂之和.例如,设X=15,Y=20,K=2,B=2,则有且仅有下列三个数满足题意: 输入:第一行包含两个整 ...
- ural1057 Amount of degrees 位数统计
#include <iostream> #include <string> using namespace std; ][]; void init(){ f[][] =; ;i ...
- [TimusOJ1057]Amount of Degrees
[TimusOJ1057]Amount of Degrees 试题描述 Create a code to determine the amount of integers, lying in the ...
- 一本通1585【例 1】Amount of Degrees
1585: [例 1]Amount of Degrees 时间限制: 1000 ms 内存限制: 524288 KB 题目描述 原题来自:NEERC 2000 Central Subr ...
- Timus Online Judge 1057. Amount of Degrees(数位dp)
1057. Amount of Degrees Time limit: 1.0 second Memory limit: 64 MB Create a code to determine the am ...
- [ACM] ural 1057 Amount of degrees (数位统计)
1057. Amount of Degrees Time limit: 1.0 second Memory limit: 64 MB Create a code to determine the am ...
随机推荐
- html基本的内容
1.表现各标签的特征 <img>中的src(source)即为属性 属性都是以"属性名 = 值"的形式出现 属性的值建议用引号括起来 属性建议均以键值对的形式括起来 一 ...
- windows下安装 sphinx 数据库全文搜索引擎
此次演示的环境是:win7系统,64位,php5.4.x,apache sphinx,斯芬克斯(英语不好的同学可以直接读这个音),意狮身人面像 特点:创建索引速度快,3分钟左右能创建100万条记录的索 ...
- ng-repeat 嵌套 ng-switch 出错解决
Error: $compile:ctreq Missing Required Controller Controller 'ngSwitch', required by directive 'ngSw ...
- HTML添加多媒体或音乐
1,添加多媒体 <embed src="多媒体文件地址" width="多媒体的宽度" height="多媒体的高度" autosta ...
- J-LINK V8固件烧录指导
1 J-LINK V8固件烧录指导 J-LINK 是使用过程中,如果内部固件意外损坏或丢失,请参考下面操作步骤说明,重新烧录JLINK固件. 1.1 安装固件烧录软件 请ATMEL官方网址下载AT91 ...
- home page
How To Set Your Home Page Step 1 – Navigate to Settings > Reading tab. Step 2 – Select A Static P ...
- LeetCode Paint Fence
原题链接在这里:https://leetcode.com/problems/paint-fence/ 题目: There is a fence with n posts, each post can ...
- spring02
1.在spring容器中的一个bean的整个生命周期 1.启动spring容器 2.bean实例化 3.装配属性 4.BeanNameAware:setBeanName 5.BeanFactoryAw ...
- erlang rabbitmq-server安装
erlang rabbitmq-server安装 yum -y install xsltproc fop tk unixODBC unixODBC-devel make gcc gcc-c++ k ...
- jpg转png
对于jpg图片来说,有损压缩因子设置为0.5 可以大大减少图片的体积,而对图片的质量几乎没有太大影响: 下面是测试图片结果: // UIImage *image_jpg = [UIImage ...