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. cordova环境搭建,搭建项目,以及拍照功能的实现

    一.配置环境 1.配置java环境: 下载对应系统环境的jdk:http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-13 ...

  2. 0040 Linux 系统管理命令

    1. 主机名称 hostname hostnamectl 2.开机启动 chkconfig systemctl 3.服务管理 service 服务名  start service 服务名  stop ...

  3. spring.xml中的配置

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  4. centos 装VBOX

    #cd /etc/yum.repos.d/wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repoyum inst ...

  5. String类和StringBuffer类的方法

    一.String类的方法 public char charAt(int index)          返回字符串index个字符 public int length()         返回字符串长 ...

  6. Install PaddlePaddle (Parallel Distributed Deep Learning)

    Step 1: Install docker on your linux system (My linux is fedora) https://docs.docker.com/engine/inst ...

  7. 使用jQuery Mobile的注意事项(译)

    翻译编辑自:http://www.appnovation.com/blog/7-things-know-about-jquery-mobile-working-it 一.Android和IOS的内置键 ...

  8. CentOS7下安装Tomcat

    1.下载tomcat. 测试tomcat版本为:apache-tomcat-8.5.6.tar.gz.下载地址:http://tomcat.apache.org/download-80.cgi. 2. ...

  9. 一张图让你看懂各开源License[转]

    你是否遇到过开源License,精炼而又晦涩的文字通常要读半天才能理解,而且大多数License差别不大,容易混淆.下面这张图让你段时间迅速掌握各种开源的License. 图片来源:阮一峰的博客. f ...

  10. McAfee重返科技业 研制D-Central防政府监视

    新闻链接:http://tech.qq.com/a/20131008/016127.htm 新闻时间: 10月8日编译 新闻正文:McAfee重返科技业 研制D-Central防政府监视 约翰·迈克菲 ...