link:http://acm.timus.ru/problem.aspx?space=1&num=1057

论文: 浅谈数位类统计问题  刘聪

 #include <iostream>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <cmath>
 #include <cctype>
 #include <algorithm>
 #include <queue>
 #include <deque>
 #include <queue>
 #include <list>
 #include <map>
 #include <set>
 #include <vector>
 #include <utility>
 #include <functional>
 #include <fstream>
 #include <iomanip>
 #include <sstream>
 #include <numeric>
 #include <cassert>
 #include <ctime>
 #include <iterator>
 const int INF = 0x3f3f3f3f;
 ][] = {{-,},{,},{,-},{,},{-,-},{-,},{,-},{,}};
 using namespace std;
 ][];
 int bto2(int x, int b)
 {
     ], cnt = , ans = ;
     while (x)
     {
         tm[cnt++] = x % b; x /= b;
     }
     ; i >= ; --i)
     {
         ))
         {
             ans += ((<<(i+))-); break;
         }
         <<i);
     }
     return ans;
 }
 int calc(int x, int k)
 {
     , ans = ;
     ; i > ; --i)
     {
         <<i))
         {
             ++tot; if (tot > k) break;
             x = x ^ (<<i);
         }
         <<(i - )) <= x) ans += (a[i-][k-tot]);
     }
     if (tot + x == k) ++ans;
     return ans;
 }
 int main(void)
 {
     #ifndef ONLINE_JUDGE
     freopen("in.txt", "r", stdin );
     #endif // ONLINE_JUDGE
     int x,y,k,b;
     memset(a, , sizeof(a));
     a[][] = ;
     ; i <= ; ++i)
     {
         a[i][] = a[i-][];
         ; j <= i; ++j) a[i][j] = a[i-][j] + a[i-][j-];
     }
     while (~scanf("%d%d%d%d",&x, &y, &k, &b))
     {
         ;
         )
         {
             ans = calc(y, k) - calc(x - , k);
         }
         else
         {
             , b), Y = bto2(y, b);
             ans = calc(Y, k) - calc(X, k);
         }
         printf("%lld\n", ans);
     }
     ;
 }

走吧,小胖!

ural 1057Amount of Degrees ——数位DP的更多相关文章

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

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

  2. URAL 1057. Amount of Degrees(数位DP)

    题目链接 我看错题了...都是泪啊,不存在3*4^2这种情况...系数必须为1... #include <cstdio> #include <cstring> #include ...

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

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

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

  5. 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 ...

  6. ural 1057(数位dp)

    数位dp题,关键是用树的思维去考虑. 对于一个数字X,要是能表示成K个B的不同次幂,等价于X在B进制下有且只有K个位上面的数字为一,其他位上的数字都为0. 具体读者可以去参考,国家集训队李聪的论文,里 ...

  7. 2018.09.07 Amount of degrees(数位dp)

    描述 求给定区间[X,Y]中满足下列条件的整数个数:这个数恰好等于K个互不相等的B的整数次幂之和. 例如,设X=15,Y=20,K=2,B=2,则有且仅有下列三个数满足题意: 17 = 24+20, ...

  8. URAL 1057 数位dp

    题目传送门http://acm.timus.ru/problem.aspx?space=1&num=1057 最近在学习数位dp,具体姿势可以参照这篇论文:http://wenku.baidu ...

  9. 【数位DP】[LOJ10163]Amount of Degrees

    发现自己以前对数位DP其实一窍不通... 这题可以做一个很简单的转换:一个数如果在$b$进制下是一个01串,且1的个数恰好有k个,那么这个数就是合法的(刚开始没判断必定是01串,只判断了1的个数竟然有 ...

随机推荐

  1. End Routine

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  2. (原创)IP协议Header部分的Checksum计算方法

  3. iOS Build Setting证书设置

    发布的用distribution debug的用development, debug是调试模式, 除非需要日志, 内部测试的时候, 才要debug模式的. release的用distribution

  4. JavaScript学习笔记及知识点整理_3

    1.js的事件冒泡及阻止方法:事件冒泡的概念:在一个对象上触发某类事件(比如单击onclick事件),如果此对象定义了此事件的处理程序,那么此事件就会调用这个处理程序,如果没有定义此事件处理程序或者事 ...

  5. mac下使用brew安装ffmpeg支持x265

    使用brew install ffmpeg 安装ffmpeg默认是没有支持x265的, 使用brew info ffmpeg 获取安装选项帮助, 使用brew reinstall ffmpeg --w ...

  6. urlencode 和 rawurlencode 的区别

    urlencode和rawurlencode的区别urlencode和rawurlencode的区别 $str1 = urlencode(':/?= &#'); $str2 = rawurle ...

  7. 转: Vue.js——60分钟组件快速入门(上篇)

    转自: http://www.cnblogs.com/keepfool/p/5625583.html Vue.js——60分钟组件快速入门(上篇)   组件简介 组件系统是Vue.js其中一个重要的概 ...

  8. thinkPHP 数字字典

  9. 并发编程 05—— Callable和Future

    Java并发编程实践 目录 并发编程 01—— ThreadLocal 并发编程 02—— ConcurrentHashMap 并发编程 03—— 阻塞队列和生产者-消费者模式 并发编程 04—— 闭 ...

  10. hibernate基于注解的维护权反转:@OneToMany(mappedBy=)

    背景说明:首先是SSH环境下,对象基于注解的方式映射到数据库: 昨天遇到一个比较纠结的问题,@OneToMany(mappedBy="xxx"), mappedBy属性有什么用,然 ...