HDU6129 规律
题意:n个数进行m次前缀和异或和后的情况,其中$n,m(1\leq n\leq2\times10^5,1\leq m\leq10^9)$。
思路:看到m这么大,肯定要分解m的,又是异或和,二进制分解后,发现第i的位置上值为与i相距 [m分解后的各个值]位置上的异或,复杂度O(nlogm)。
/** @Date : 2017-08-18 16:10:51
* @FileName: 1010 规律.cpp
* @Platform: Windows
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version : $Id$
*/
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 5e5+20;
const double eps = 1e-8; LL a[N];
int main()
{
int T;
cin >> T;
while(T--)
{
LL n, m;
scanf("%lld%lld", &n, &m);
for(int i = 0; i < n; i++)
scanf("%lld", a + i);
for(int i = 0; i < 32; i++)
{
if((m & (1LL << i)) == 0)//注意优先级...
continue;
for(int j = 0; j < n; j++)
{
if(j - (1 << i) >= 0)
a[j] ^= a[j - (1 << i)];
//printf("%lld%s", a[j], j==n-1?"\n":" ");
} }
for(int i = 0; i < n; i++)
printf("%lld%s", a[i], i==n-1?"\n":" ");
}
return 0;
}
HDU6129 规律的更多相关文章
- 【找规律】【二进制拆分】hdu6129 Just do it
给你数列a,问你对它作m次求前缀异或和之后的新数列是什么. 考虑a1对最终生成的数列的每一位的贡献,仅仅考虑奇偶性, 当m为2的幂次的时候,恰好是这样的 2^0 1 1 1 1 1 ... 2^1 1 ...
- hdu1452 Happy 2004(规律+因子和+积性函数)
Happy 2004 题意:s为2004^x的因子和,求s%29. (题于文末) 知识点: 素因子分解:n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en 因子 ...
- Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)
传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...
- ACM/ICPC 之 DP解有规律的最短路问题(POJ3377)
//POJ3377 //DP解法-解有规律的最短路问题 //Time:1157Ms Memory:12440K #include<iostream> #include<cstring ...
- HDU 5795 A Simple Nim 打表求SG函数的规律
A Simple Nim Problem Description Two players take turns picking candies from n heaps,the player wh ...
- 在sqlserver中做fibonacci(斐波那契)规律运算
--利用sqlserver来运算斐波那契规律 --利用事物与存储过程 declare @number intdeclare @A intdeclare @B intdeclare @C int set ...
- 谈谈黑客攻防技术的成长规律(aullik5)
黑莓末路 昨晚听FM里谈到了RIM这家公司,有分析师认为它需要很悲催的裁员90%,才能保证活下去.这是一个意料之中,但又有点兔死狐悲的消息.可能在不久的将来,RIM这家公司就会走到尽头,或被收购,或申 ...
- Math.abs(~2018),掌握规律即可!
Math.abs(~2018) 某前端群的入门问题长姿势了,一个简单的入门问题却引发了我的思考,深深的体会到自己在学习前端技术的同时忽略遗忘了一些计算机的基础知识. 对于 JS Math对象没什么可说 ...
- COM中需要调用AddRef和Release的10条规律
COM中需要调用AddRef和Release的10条规律
随机推荐
- Thunder——互评beta版本
基于NABCD和spec评论作品 Hello World!:http://www.cnblogs.com/vector121/p/7922989.html 欢迎来怼:http://www.cnblog ...
- 《linux内核分析》 第二周
20135130 王川东 计算机三个“法宝”:存储程序计算机.函数调用堆栈和中断机制 深入理解函数调用堆栈: 堆栈是C语言运行时必须的一个记录调用路径和参数的空间: 作用包括: 函数调用框架: 保存参 ...
- html、JSP运行原理
HTML运行原理 1.本地运行 所谓本地运行就是直接用 浏览器打开 2.远程访问的原理示意图: 何为协议?计算机互相通信(网络)的规则.常见的协议有 http .smtp. ftp.pop等 ...
- Struts2(六)
以下内容是基于导入struts2-2.3.32.jar包来讲的 1.OGNL OGNL是Object-Graph Navigation Language的缩写,全称为对象图导航语言,是一种功能强大的表 ...
- 各种GIT代码托管工具比较
bitbucket免费支持5个开发成员的团队创建无限私有代码托管库. GOES是一个由GO语音编写的自组GIT托管服务. gitorious 是一个基于GIT版本控制系统的WEB项目托管平台,基于RU ...
- (四)Jmeter之逻辑控制器(Logic Controller)
Jmeter之逻辑控制器(Logic Controller) 前言: 1. Jmeter官网对逻辑控制器的解释是:“Logic Controllers determine the order in w ...
- selenium 概念及练习 !
1.selenium中如何判断元素是否存在? 2.selenium中hidden或者是display = none的元素是否可以定位到? 3.selenium中如何保证操作元素的成功率?也就是说如何保 ...
- (十)Jmeter中的Debug Sampler介绍
一.Debug Sampler介绍: 使用Jmeter开发脚本时,难免需要调试,这时可以使用Jmeter的Debug Sampler,它有三个选项:JMeter properties,JMeter v ...
- 设计模式PHP篇(三)————适配器模式
简单的适配器模式: interface Adaptor { public function read(); public function write(); } class File implemen ...
- 【C】多线程编程笔记
1. pthread_create(pthread类型指针变量 ,NULL ,函数 ,函数参数[多个参数用结构体传]) 2. pthread_join(pthread类型指针变量, 返回一般为null ...