题意:

对于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的更多相关文章

  1. SQL ServerAlways Encrypted Data

    SQL Server 提供了一个加密表上字段的功能, Encrypt Columns ,  比如身份证号码,手机号码,银行账户等等敏感信息.

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

  3. MSSQL-最佳实践-Always Encrypted

    摘要 在SQL Server安全系列专题月报分享中,往期我们已经陆续分享了:如何使用对称密钥实现SQL Server列加密技术.使用非对称密钥实现SQL Server列加密.使用混合密钥实现SQL S ...

  4. Oracle 11g R2 Backup Data Pump(数据泵)之expdp/impdp工具

    Oracle Data Pump(以下简称数据泵)是Oracle 10g开始提供的一种数据迁移工具,同时也被广大DBA用来作为数据库的逻辑备份工具和体量较小的数据迁移工具.与传统的数据导出/导入工具, ...

  5. encrypt and decrypt data

    https://www.cyberciti.biz/tips/linux-how-to-encrypt-and-decrypt-files-with-a-password.html Encryptin ...

  6. Note: Transparent data deduplication in the cloud

    What Design and implement ClearBox which allows a storage service provider to transparently attest t ...

  7. TENSEAL: A LIBRARY FOR ENCRYPTED TENSOR OP- ERATIONS USING HOMOMORPHIC ENCRYPTION 解读

    本文记录阅读该paper的笔记,这篇论文是TenSeal库的原理介绍. 摘要 机器学习算法已经取得了显著的效果,并被广泛应用于各个领域.这些算法通常依赖于敏感和私有数据,如医疗和财务记录.因此,进一步 ...

  8. [MySQL Reference Manual]15. 其他存储引擎

    15. 其他存储引擎 15. 其他存储引擎 15.1 设置存储引擎 15.2 MyISAM存储引擎 15.2.1 MyISAM启动选项 15.2.2 Key的空间要求 15.2.3 MyISAM表存储 ...

  9. 【机器学习Machine Learning】资料大全

    昨天总结了深度学习的资料,今天把机器学习的资料也总结一下(友情提示:有些网站需要"科学上网"^_^) 推荐几本好书: 1.Pattern Recognition and Machi ...

随机推荐

  1. Hdu-1565 方格取数(1) (状态压缩dp入门题

    方格取数(1) Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  2. 轻松搞定RabbitMQ(一)——RabbitMQ基础知识+HelloWorld

    转自 http://blog.csdn.net/xiaoxian8023/article/details/48679609 本文是简单介绍一下RabbitMQ,参考官网上的教程.同时加入了一些自己的理 ...

  3. ajax短信验证码-mvc

    <script type="text/javascript"> function SendMessage() { var phoneNumberInput = docu ...

  4. HDU 3308 LCIS (线段树&#183;单点更新&#183;区间合并)

    题意  给你一个数组  有更新值和查询两种操作  对于每次查询  输出相应区间的最长连续递增子序列的长度 基础的线段树区间合并  线段树维护三个值  相应区间的LCIS长度(lcis)  相应区间以左 ...

  5. poj 1163 The Triangle &amp;poj 3176 Cow Bowling (dp)

    id=1163">链接:poj 1163 题意:输入一个n层的三角形.第i层有i个数,求从第1层到第n层的全部路线中.权值之和最大的路线. 规定:第i层的某个数仅仅能连线走到第i+1层 ...

  6. Leetcode 002-Search Insert Position

    #Given a sorted array and a target value, return the index if the target is found. If not, return th ...

  7. Bullet Physics OpenGL 刚体应用程序模板 Rigid Simulation in Bullet

    利用Bullet物理引擎实现刚体的自由落体模拟的模板 Bullet下载地址 Main.cpp #include <GLUT/glut.h> #include <cstdlib> ...

  8. P1355 神秘大三角

    题目描述 判断一个点与已知三角形的位置关系. 输入输出格式 输入格式: 前三行:每行一个坐标,表示该三角形的三个顶点 第四行:一个点的坐标,试判断该点与前三个点围成三角形的位置关系 (详见样例) 所有 ...

  9. Vue入门(一) 环境配置

    Node.js 安装,https://nodejs.org/en/  默认安装就可以 安装好后测试版本,cmd  键入命令 1.node -v 2.npm -v 安装,淘宝 NPM         n ...

  10. port_443

    GRC | Port Authority, for Internet Port 443 https://www.grc.com/port_443.htm