题意:给你一个包含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 ;
}

HDU 6129 Just do it的更多相关文章

  1. HDU 6129 - Just do it | 2017 Multi-University Training Contest 7

    比赛时脑子一直想着按位卷积... 按题解的思路: /* HDU 6129 - Just do it [ 规律,组合数 ] | 2017 Multi-University Training Contes ...

  2. HDU 6129 Just do it(杨辉三角)

    http://acm.hdu.edu.cn/showproblem.php?pid=6129 题意: 给出数组a,并且bi=a1^a2^a3...^ai,并且现在会重复m次,求出最后的b数组. 思路: ...

  3. 2017多校第7场 HDU 6129 Just do it 找规律

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6129 题意:求a序列后m次xor前缀和 解法: 手动对1位置对每个位置的贡献打表发现 第一次 贡献为 ...

  4. 【(好题)组合数+Lucas定理+公式递推(lowbit+滚动数组)+打表找规律】2017多校训练七 HDU 6129 Just do it

    http://acm.hdu.edu.cn/showproblem.php?pid=6129 [题意] 对于一个长度为n的序列a,我们可以计算b[i]=a1^a2^......^ai,这样得到序列b ...

  5. 2017ACM暑期多校联合训练 - Team 7 1010 HDU 6129 Just do it (找规律)

    题目链接 Problem Description There is a nonnegative integer sequence a1...n of length n. HazelFan wants ...

  6. HDU - 6129 :Just do it (杨辉三角)

    There is a nonnegative integer sequence a 1...n  a1...n of length n n . HazelFan wants to do a type ...

  7. HDU 6129 Just do it ——(找规律)

    思路见:http://blog.csdn.net/qq_32506797/article/details/77206167. 利用二进制讲m次转化成log次然后进行转移. 代码如下: #include ...

  8. Codechef WEASELTX

    WEASELTX code给你一棵 n 个节点的有根树(节点),以及每个节点 i 的初始权值 a[i] .一次操作则是指将每个节点的权值变为以其为根的子树中所有节点的权值之异或和.维护 q 个询问,每 ...

  9. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

随机推荐

  1. vue 定时器的问题

    在项目中,我们经常会使用到定时器setInterval(),可是很多时候我们会发现,即使我退出当前页面,定时器依然在工作,非常消耗内存,所以我们要进行手动清理: 将定时器保存在变量中,退出页面时清除变 ...

  2. 第四章 栈与队列(d)队列接口与实现

  3. 关于RAID的概述

    Raid 0:一块硬盘或者以上就可做raid0优势:数据读取写入最快,最大优势提高硬盘容量,比如3快80G的硬盘做raid0 可用总容量为240G.速度是一样.缺点:无冗余能力,一块硬盘损坏,数据全无 ...

  4. CentOS Find命令

    find命令用来在指定目录下查找文件.任何位于参数之前的字符串都将被视为欲查找的目录名.如果使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目录与文件.并且将查找到的子目录和文件全部进 ...

  5. word2vec详解与实战

    有那么一句话 不懂word2vec,就别说自己是研究人工智能->机器学习->自然语言处理(NLP)->文本挖掘的 所以接下来我就从头至尾的详细讲解一下word2vec这个东西. 简要 ...

  6. decay

    decay - 必应词典 美[dɪ'keɪ]英[dɪ'keɪ] v.衰减:腐朽:衰败 n.腐烂:衰退:腐朽 网络衰变:腐败 变形过去分词:decayed:现在分词:decaying:第三人称单数:de ...

  7. Python开发【第四篇】:模块

    双层装饰器示例 __author__ = 'Golden' #!/usr/bin/env python # -*- coding:utf-8 -*-     USER_INFO = {}     de ...

  8. Framework7框架结构

    以2017年2月10日发布的Framework7 1.5.3为例. (function(){ 'use strict'; window.Framework7 = function(){ var app ...

  9. Python: 浅淡Python中的属性(property)

    起源:项目过程中需要研究youtube_dl这个开源组件,翻阅其中对类的使用,对比c#及Delphi中实现,感觉Python属性机制挺有意思.区别与高级编程语言之单一入口,在类之属性这一方面,它随意的 ...

  10. Bootstrap(3) 表格与按钮

    1.表格 基本格式,实现基本的表格样式 <table class="table"> <thead> <tr> <th>编号</ ...