Sherlock and the Encrypted Data
题意:
对于16进制数字num,假定 $p_0,p_1,...,p_m$ 在该数字中出现过,如果有 $x = 2^{p_0} + 2^{p_1} + ... + 2^{p_m}$
且 $x \oplus num < num$ 则认为 $F(num) = 1$, 不然 $F(num) = 0$
求$\sum_{i=L}^R {F(i)}$
解法:
考虑 $F(num) = 1$ 的条件,注意到如果有 $x \oplus num < num$,相当于 $num$ 二进制的 $p_m$ 位为1。
这样考虑数位dp。
对于确定位,我们记一下最大值。
对于不确定位,我们枚举一下全局最大值 $p_m$,然后枚举一下 $p_m / 4 +1$ 位可以的16进制的值,然后快速幂+容斥算一下即可。
#include <iostream>
#include <cstdio>
#include <cstring> #define LL long long
#define N 110
#define bit(t) (1<<(t)) using namespace std; int q,num[N],dig[N]; LL qpow(LL x,int n)
{
LL ans=;
for(;n;n>>=,x=x*x) if(n&) ans=ans*x;
return ans;
} LL calc(int m,int tot,int maxnow)
{
LL ans=;
for(int t=;t>=maxnow;t--)
{
int x = t/+;
int tmp = t%;
if(x > tot) continue;
for(int S=;S<(<<);S++)
{
int now=bit(tmp);
for(int i=;i<;i++)
if(bit(i)&S) now|=bit((tmp+i+)%);
if(now > t || (dig[x]!=- && dig[x]!=now)) continue;
int cnt=m;
if(dig[x]==-) cnt--;
if(now == t || maxnow == t) ans += qpow(t+, cnt);
else ans += qpow(t+, cnt) - qpow(t, cnt);
}
}
return ans;
} LL calc(char *S,bool inc)
{
memset(num,,sizeof(num));
int tot=strlen(S);
for(int i=;i<tot;i++)
{
if(S[i]<='' && S[i]>='') num[tot-i] = S[i]-'';
else num[tot-i] = S[i]-'a'+;
}
if(inc)
{
num[]++;
for(int i=;i<=tot;i++)
if(num[i]>=) num[i]-=,num[i+]++;
if(num[tot+]) tot++;
}
for(int i=;i<=tot;i++) dig[i]=-;
LL ans = ;
int maxnow=;
for(int i=tot;i>=;i--)
{
for(int j=;j<num[i];j++)
dig[i]=j, ans += calc(i-, tot, max(maxnow,j));
dig[i]=num[i];
maxnow=max(maxnow,dig[i]);
}
return ans;
} char L[N],R[N]; int main()
{
int q;
cin>>q;
while(q--)
{
cin>>L>>R;
cout<<calc(R,)-calc(L,)<<endl;
}
return ;
}
Sherlock and the Encrypted Data的更多相关文章
- SQL ServerAlways Encrypted Data
SQL Server 提供了一个加密表上字段的功能, Encrypt Columns , 比如身份证号码,手机号码,银行账户等等敏感信息.
- TDE: Transparent Data Encryption brief introduction
1. What is TDE? Briefly speaking, TDE is used to encrypted data. 2. The benifits: Belows are come fr ...
- MSSQL-最佳实践-Always Encrypted
摘要 在SQL Server安全系列专题月报分享中,往期我们已经陆续分享了:如何使用对称密钥实现SQL Server列加密技术.使用非对称密钥实现SQL Server列加密.使用混合密钥实现SQL S ...
- Oracle 11g R2 Backup Data Pump(数据泵)之expdp/impdp工具
Oracle Data Pump(以下简称数据泵)是Oracle 10g开始提供的一种数据迁移工具,同时也被广大DBA用来作为数据库的逻辑备份工具和体量较小的数据迁移工具.与传统的数据导出/导入工具, ...
- encrypt and decrypt data
https://www.cyberciti.biz/tips/linux-how-to-encrypt-and-decrypt-files-with-a-password.html Encryptin ...
- Note: Transparent data deduplication in the cloud
What Design and implement ClearBox which allows a storage service provider to transparently attest t ...
- TENSEAL: A LIBRARY FOR ENCRYPTED TENSOR OP- ERATIONS USING HOMOMORPHIC ENCRYPTION 解读
本文记录阅读该paper的笔记,这篇论文是TenSeal库的原理介绍. 摘要 机器学习算法已经取得了显著的效果,并被广泛应用于各个领域.这些算法通常依赖于敏感和私有数据,如医疗和财务记录.因此,进一步 ...
- [MySQL Reference Manual]15. 其他存储引擎
15. 其他存储引擎 15. 其他存储引擎 15.1 设置存储引擎 15.2 MyISAM存储引擎 15.2.1 MyISAM启动选项 15.2.2 Key的空间要求 15.2.3 MyISAM表存储 ...
- 【机器学习Machine Learning】资料大全
昨天总结了深度学习的资料,今天把机器学习的资料也总结一下(友情提示:有些网站需要"科学上网"^_^) 推荐几本好书: 1.Pattern Recognition and Machi ...
随机推荐
- Install Server Backup Manager on CentOS, RHE, and Fedora
Skip to end of metadata Added by Internal, last edited by Internal on Aug 25, 2014 Go to start of me ...
- iOS8 Push Notifications
本文转载至 http://blog.csdn.net/pjk1129/article/details/39551887 原贴地址:https://parse.com/tutorials/ios-p ...
- Running several name-based web sites on a single IP address.
VirtualHost Examples - Apache HTTP Server Version 2.2 http://httpd.apache.org/docs/2.2/vhosts/exampl ...
- mybatis是什么?(二)
mybatis是什么? mybatis是一个持久层的框架,是apache下的顶级项目. mybatis托管到goolecode下,再后来托管到github下(https://github.com/my ...
- duilib查看过的资料整理
1.duilib中各个类的简单介绍 2.源码分析 3.各个控件可以设置的属性 4.duilib的消息流程处理 5.工程编译入门 6.MFC中混合使用duilib制作界面 7.从Win32窗口到duil ...
- RNN 的入门程序DEMO
1.视频介绍 https://www.youtube.com/watch?v=cdLUzrjnlr4 2. https://github.com/llSourcell/recurrent_neural ...
- 将前端文件和Go程序打包
我今天项目上碰见个需求,前端小哥给我写了个页面,要搭配我的Go程序一起使用,突然想到Go可以打包静态页面,而且调用也很方便,所以操作了一下,成功,我把它记录下来,作为以后的回顾和复习. 首先,我们需要 ...
- vue路由总结
vue-router, vue自带的路由,下面是一些简单的操作说明: 一.安装 1.cnpm install vue-router --save 命令进行安装 2.在main.js或者使用vue-r ...
- Window 64位下的客户机配置PLSQL链接远程Oracle
此文章记录的是艰难探索. 完成如下工作: 服务器A为Windows Serve 2016:安装Oracle. 客户机B为Win7 x64位,安装PLSQLDevelop,链接A上的Oracle. 首先 ...
- zkdash部署
1.拉取代码 #git clone https://github.com/ireaderlab/zkdash.git 2.安装依赖包 #cd zkdash #yum install -y python ...