HDU6129-Just do it
来源:互联网 发布:ubuntu gcc离线安装包 编辑:程序博客网 时间:2024/06/07 06:05
Just do it
Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 719 Accepted Submission(s): 415
Problem Description
There is a nonnegative integer sequence a1...n of length n . HazelFan wants to do a type of transformation called prefix-XOR, which means a1...n changes into b1...n , where bi equals to the XOR value of a1,...,ai . He will repeat it for m times, please tell him the final sequence.
Input
The first line contains a positive integer T(1≤T≤5) , denoting the number of test cases.
For each test case:
The first line contains two positive integersn,m(1≤n≤2×105,1≤m≤109) .
The second line containsn nonnegative integers a1...n(0≤ai≤230−1) .
For each test case:
The first line contains two positive integers
The second line contains
Output
For each test case:
A single line containsn nonnegative integers, denoting the final sequence.
A single line contains
Sample Input
21 113 31 2 3
Sample Output
11 3 1
Source
2017 Multi-University Training Contest - Team 7
解题思路:我们可以找出经过每一轮后的每个数字是由哪些数字异或得到的,比如对于题目中给出的a[1],我们可以找出经过每一轮后哪些数字是由它异或得到的,后面的数字就是将这个表往右移一位
#include <iostream>#include <cstdio>#include <cstring>#include <map>#include <set>#include <string>#include <cmath>#include <algorithm>#include <vector>#include <bitset>#include <stack>#include <queue>#include <unordered_map>#include <functional>using namespace std;const int INF=0x3f3f3f3f;#define LL long longint ans[200009],a[200009];int dfs(int x,int y,int len){ if(x>len/2&&y>len/2) return 0; if(x==1||y==1) return 1; if(x>len/2) return dfs(x-len/2,y,len/2); else if(y>len/2) return dfs(x,y-len/2,len/2); else return dfs(x,y,len/2);}int main(){ int t,n,m; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++)scanf("%d",&a[i]); memset(ans,0,sizeof ans); int k=2; while(k<n) k*=2; m%=k; if(!m) m=k; for(int i=1;i<=n;i++) { if(dfs(m,i,k)) { for(int j=i;j<=n;j++) ans[j]^=a[j-i+1]; } } int flag=0; for(int i=1;i<=n;i++) { if(flag) printf(" "); else flag=1; printf("%d",ans[i]); } printf("\n"); } return 0;}
阅读全文
0 0
- HDU6129-Just do it
- hdu6129 Just do it
- HDU6129 Just do it
- HDU6129-Just do it
- HDU6129 Just do it【规律】
- HDU6129 Just do it (找规律)
- hdu6129 just do it 递推 思维
- HDU6129 Just do it[组合数学]
- Hdu6129 Just do it(2017多校第7场)
- Just do it————(多校第7场 hdu6129)
- HDU6129 Just do it(前缀异或+杨辉三角)
- hdu6129 Just do it 2017多校第七场1010 杨辉三角+规律
- Just do it
- Just do it!
- Just do it!
- Just do it!
- just do it!
- Just do it!
- 第100篇博客
- 技术文章 | 阿里云前端周刊
- openstack storlet文档(五):storlet API
- 简单理解Socket
- 神经网络卷积结构及计算过程
- HDU6129-Just do it
- nginx(2) 配置站点示例
- Android EventBus源码解析 带你深入理解EventBus
- python实现简单redis客户端(1)
- 2017.8.16 pyton实现登录界面
- CSU 1019: Simple Line Editor(模拟)
- 创建UDF的简单方法介绍
- java高并发
- Swift宏定义