#include <iostream>
#include <string>
using namespace std; int f[][];
void init(){
f[][] =;
for(int i=;i<=;i++){
f[i][] = f[i-][];
for(int j=;j<=i;j++)
f[i][j] = f[i-][j]+f[i-][j-];
}
} int change(int x,int b){
string s;
while(x){
s = (char)(x%b+'')+s;
x = x/b;
}
for(int i=;i<s.size();i++)
if(s[i]>''){
for(int j=i;j<s.size();j++)
s[j] = '';
break;
}
x =;
for(int i=;i<s.size();i++){
x = x|((s[s.size()--i]-'')<<i);
}
return x;
} int cal(int x,int k){
int tot =,ans =;
for(int i=;i>;i--){
if(x&(<<i)){
tot++;
if(tot>k) break;
x = x^(<<i);
}
if((<<(i-))<=x){
ans += f[i-][k-tot];
}
}
if(tot + x==k) ans++;
return ans;
} int main()
{
init();
int x,y;
int k,b;
cin>>x>>y>>k>>b;
x= change(x,b);
y = change(y,b);
int resx = cal(x-,k);
int resy = cal(y,k);
cout<<resy-resx<<endl;
return ;
}

ural1057 Amount of degrees 位数统计的更多相关文章

  1. [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 ...

  2. [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 ...

  3. Ural1057. Amount of Degrees 题解 数位DP

    题目链接: (请自行百度进Ural然后查看题号为1057的那道题目囧~) 题目大意: Create a code to determine the amount of integers, lying ...

  4. Ural1057 - Amount of Degrees(数位DP)

    题目大意 求给定区间[X,Y]中满足下列条件的整数个数:这个数恰好等于K个互不相等的B的整数次幂之和.例如,设X=15,Y=20,K=2,B=2,则有且仅有下列三个数满足题意: 输入:第一行包含两个整 ...

  5. ural1057 Amount of Degrees

    链接 这题有一点小坑点 就是AX^B  A只能为0或者1  ,剩下的就比较好做的了. #include <iostream> #include<cstdio> #include ...

  6. URAL1057. Amount of Degrees(DP)

    1057 简单的数位DP  刚开始全以2进制来算的 后来发现要找最接近x,y值的那个基于b进制的0,1组合 #include <iostream> #include<cstdio&g ...

  7. 一本通1585【例 1】Amount of Degrees

    1585: [例 1]Amount of Degrees 时间限制: 1000 ms         内存限制: 524288 KB 题目描述 原题来自:NEERC 2000 Central Subr ...

  8. Ural Amount of Degrees(数位dp)

    传送门 Amount of Degrees Time limit: 1.0 secondMemory limit: 64 MB Description Create a code to determi ...

  9. [TimusOJ1057]Amount of Degrees

    [TimusOJ1057]Amount of Degrees 试题描述 Create a code to determine the amount of integers, lying in the ...

随机推荐

  1. 使用 NuGet 管理项目库

    使用 NuGet 管理项目库 Phil Haack 本文转载自:http://msdn.microsoft.com/zh-cn/magazine/hh547106.aspx 无论多么努力,Micros ...

  2. Javascript 中创建自定义对象的方法(设计模式)

    Javascript 中创建对象,可以有很多种方法. Object构造函数/对象字面量: 抛开设计模式不谈,使用最基本的方法,就是先调用Object构造函数创建一个对象,然后给对象添加属性. var ...

  3. 调度器(scheduler)

    调度器(schedule)为游戏提供定时事件和定时调用服务. 调度器(schedule)的功能和事件监听器(eventlistener)的功能有点类似:都是在特定情况下调用某个事先准备好的回调函数. ...

  4. Spring jdbcTemplate + EasyUI 物理分页

    前文说到,新项目中,用到的是SpringMVC + jdbcTemplate,前台是EasyUI,发现同事以前封装分页是逻辑分页,于是,自己动手封装了下物理分页. 这个是核心分页实体: import ...

  5. $()和getElementById()的区别

    jQuery的成功多归功于其强大的选择器. 然而,相信不少初学jQuery的同学都会遇到下面的问题. 在javascript下,我们可以根据getElementById()来获取页面元素.如下: va ...

  6. R与数据分析旧笔记(六)多元线性分析 上

    > x=iris[which(iris$Species=="setosa"),1:4] > plot(x) 首先是简单的肉眼观察数据之间相关性 多元回归相较于一元回归的 ...

  7. 条件注释+JS实现各版本IE浏览器className

    最近又开始忙了,项目中又遇到了可恶的IE Hack问题,各种Hack的看着让自己都觉得恶心,于是决定改造一番. 首先请出条件注释语句: 之前用过的条件注释 <!--[if lt IE 7]> ...

  8. JS 操作日期

    var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份(4位,1970-???? ...

  9. 工作日志2014-06-10(实现C语言解析XML获得查询关键字)

    #include "GetInfo.h" ]; int GetInfoToWrite(char* path, char* domain,Write_t* pwrite); int ...

  10. JAVA并发,同步锁性能测试

    测试主要从运行时间差来体现,数据量越大,时间差越明显,例子如下: package com.xt.thinks21_2; /** * 同步锁性能测试 * * @author Administrator ...