ural 1057Amount of Degrees ——数位DP
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的更多相关文章
- Ural1057 - Amount of Degrees(数位DP)
题目大意 求给定区间[X,Y]中满足下列条件的整数个数:这个数恰好等于K个互不相等的B的整数次幂之和.例如,设X=15,Y=20,K=2,B=2,则有且仅有下列三个数满足题意: 输入:第一行包含两个整 ...
- URAL 1057. Amount of Degrees(数位DP)
题目链接 我看错题了...都是泪啊,不存在3*4^2这种情况...系数必须为1... #include <cstdio> #include <cstring> #include ...
- [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 ...
- 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 ...
- ural 1057(数位dp)
数位dp题,关键是用树的思维去考虑. 对于一个数字X,要是能表示成K个B的不同次幂,等价于X在B进制下有且只有K个位上面的数字为一,其他位上的数字都为0. 具体读者可以去参考,国家集训队李聪的论文,里 ...
- 2018.09.07 Amount of degrees(数位dp)
描述 求给定区间[X,Y]中满足下列条件的整数个数:这个数恰好等于K个互不相等的B的整数次幂之和. 例如,设X=15,Y=20,K=2,B=2,则有且仅有下列三个数满足题意: 17 = 24+20, ...
- URAL 1057 数位dp
题目传送门http://acm.timus.ru/problem.aspx?space=1&num=1057 最近在学习数位dp,具体姿势可以参照这篇论文:http://wenku.baidu ...
- 【数位DP】[LOJ10163]Amount of Degrees
发现自己以前对数位DP其实一窍不通... 这题可以做一个很简单的转换:一个数如果在$b$进制下是一个01串,且1的个数恰好有k个,那么这个数就是合法的(刚开始没判断必定是01串,只判断了1的个数竟然有 ...
随机推荐
- 06-scanf函数
本文目录 变量的内存分析 scanf函数 回到顶部 一. 变量的内存分析 1. 字节和地址 为了更好地理解变量在内存中的存储细节,先来认识一下内存中的“字节”和“地址”. 1> 内存以“字节为单 ...
- shockt通信
目前为止,我们使用的最多网络协议还是tcp/ip网络.通常来说,我们习惯上称为tcp/ip协议栈.至于协议栈分成几层,有两种说法.一种是五层,一种是七层. 5.应用层 4.传输层 3.网络 ...
- python中Scikit-Learn机器学习模块
Scikit-Learn是基于python的机器学习模块,基于BSD开源许可证.这个项目最早由DavidCournapeau 在2007 年发起的,目前也是由社区自愿者进行维护. Scikit-Lea ...
- c语言->和 .
->和 . 都是用于访问结构数据的符号. struct point { int x; int y; }; . 符号是在表达式中引用某个特定结构中的成员: 结构名.成员 例如: struct po ...
- centos7 禁止防火墙
#CentOS .0默认使用的是firewall作为防火墙,这里改为iptables防火墙. #firewall: systemctl start firewalld.service#启动firewa ...
- 高版本正方教务系统上传后缀过滤不严导致能直接上传Webshell
在旧版本中有一个利用插件上传文件的漏洞,但是在新版本中已经没有了这个插件.这个漏洞是由于过滤不严造成的,可以直接上传Webshell进行提权,由于代码在DLL中,全国大部分高校均有此漏洞,影响范围很大 ...
- PowerDesigner导出建表sql脚本
1 按照数据库类型,切换数据库. Database-> Change Current DBMS... 2.设置保存路径和文件名称
- git删除远程仓库的某次错误提交
改日写git的各种本地恢复 今天不小心把一个分支合并到master上了,上网查了一下回复的方法,简单来说就是: 在本地 把远程的master分支删除再把reset后的分支内容给push上去 新建old ...
- mysql 二进制日志
1.日志类型 二进制日志记录了所有对mysql数据库的修改事件,包括增删改事件和对表结构的修改事件. 2.配置使用二进制日志 在my.ini 配置 log-bin=mysql-bin ...
- WCF初探-23:WCF中使用Message类(下)
前言 在上一篇WCF中使用Message类(上)中,文章介绍了WCF中使用Message类的基本知识和怎样创建消息,本文是承接上一篇文章,如果想要更好的阅读本文,请先阅读上一篇文章.在这篇文章中,我将 ...