博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[HDU5968]异或密码
阅读量:7055 次
发布时间:2019-06-28

本文共 866 字,大约阅读时间需要 2 分钟。

[HDU5968]异或密码

题目大意:

数据共\(T(T\le100)\)组。每组给定一个长度为\(n(n\le100)\)的非负整数序列\(A(A_i\le1024)\)\(m(m\le100)\)个询问,每个询问包含一个整数\(x_i(|x_i|\le1024)\)。求该序列的子区间异或和与\(x_i\)接近程度值最小的区间长度;若有多个区间的异或和与\(x_i\)的接近程度值相同,则回答最长的区间长度。

思路:

求前缀异或和之后暴力枚举区间端点即可。

源代码:

#include
#include
#include
#include
inline int getint() { register char ch; register bool neg=false; while(!isdigit(ch=getchar())) neg|=ch=='-'; register int x=ch^'0'; while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0'); return neg?-x:x;}const int N=101;int a[N];int main() { for(register int T=getint();T;T--) { const int n=getint(); for(register int i=1;i<=n;i++) { a[i]=a[i-1]^getint(); } const int m=getint(); for(register int i=0;i

转载于:https://www.cnblogs.com/skylee03/p/9812442.html

你可能感兴趣的文章
解决docker容器中无ifconfig命令和ping命令问题
查看>>
CHAR、TCHAR、WCHAR_T之间的区别与问题
查看>>
sql小计合计
查看>>
安装Java
查看>>
Ubuntu Linux输入法fcitx方块乱码解决设置
查看>>
node递归批量重命名指定文件夹下的文件
查看>>
python if not用法
查看>>
python-2
查看>>
选择器
查看>>
springMVC参数的获取区别
查看>>
win7电脑数字键盘失灵怎么办
查看>>
java及java web学习笔记
查看>>
SpringMVC+Spring+hibernate整合及分页
查看>>
OpenAI教程
查看>>
LeetCode:459. Repeated Substring Pattern
查看>>
Database Resource website
查看>>
牛客寒假6-E.海啸
查看>>
linq 读取xml
查看>>
const 总结
查看>>
@RestController注解下返回到jsp视图页面
查看>>