题意:给你一个包含n个数的序列A和一个数m,序列B中的数是序列A经过异或得到的,比如:b[i]=a[1]^a[2]^…..^a[i]。现在让你求经过m次异或后,序列B的值。

   思路:这题其实和杨辉三角形有关。

   首先我们打个表可以得到

  

  我们知道杨辉三角形

  我们可以看到一个规律,我们单独把a提出来,每一行便是

  我们斜着看杨辉三角形

  可以发现是相等的,我们就得到结论(i,j)位置的数值等于C(i+j-2, j-1),判断此处的奇偶便好。

/** @xigua */
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <climits>
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 2e5 + ;
const int mod = 1e9 + ;
const int INF = 1e8 + ;
const ll inf = 1e15 + ;
const db eps = 1e-;
int a[maxn], b[maxn]; void solve() {
int n, m; scanf("%d%d", &n, &m);
memset(b, , sizeof(b));
memset(a, , sizeof(a));
for (int i=; i<=n; i++) scanf("%d", &a[i]);
for (int i=; i<=n; i++) {
int x=i+m-, y=i-;
if ((x&y)==y) {  //判断奇偶
for (int j=i; j<=n; j++)
b[j]^=a[j-i+];
}
}
for (int i=; i<=n; i++) {
if (i-) printf(" ");
printf("%d", b[i]);
}
puts("");
}
int main() {
int t = , cas = ;
//freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
scanf("%d", &t);
while(t--) {
// printf("Case %d: ", cas++);
solve();
}
return ;
}

最新文章

  1. Cobar + MySQL 技术验证(li)
  2. static
  3. NodeJs使用asyncAwait两法
  4. Android-----工程文件目录介绍
  5. linux 多个python版本的切换
  6. Win7无法使用VPN的原因与解决方法(一)
  7. [VirtualBox] Install Ubuntu 14.10 error 5 Input/output error
  8. Ext 面向对象程序设计 入门篇
  9. C++之拷贝构造函数
  10. D3DXMatrixMultiply 函数
  11. autorun.vbs病毒的清除办法
  12. 使用face_recognition批量识别图片中的人数
  13. Linq 等式运算符:SequenceEqual
  14. Java-NIO(五):通道(Channel)的数据传输与内存映射文件
  15. AutoFac+MVC+WebApi源码----我踩过的坑
  16. 【网站seo优化】SEO优化每天的工作内容是什么?
  17. 46.HTML---18个学习 flexbox 的优质资源
  18. Eclipse无法使用springboot2.x
  19. java获取路径(转)
  20. RSS Feeds with Spring Boot

热门文章

  1. ORACLE 如何产生一个随机数
  2. TCP和UDP协议的比较
  3. poj1308(并查集)
  4. pta l2-5(集合相似度)
  5. CentOS 下环境变量
  6. The Attention Merchants
  7. [leetcode]692. Top K Frequent Words K个最常见单词
  8. Linux配置Nginx负载均衡
  9. 13-linux定时任务不起作用到的问题解决办法
  10. centos7下docker1.12.5学习笔记