A. Mocha and Math(codeforces#738(div2))

简介: A. Mocha and Math(codeforces#738(div2))

A. Mocha and Math


time limit per test


1 second


memory limit per test


256 megabytes


input


standard input


output


standard output


Mocha is a young girl from high school. She has learned so much interesting knowledge from her teachers, especially her math teacher. Recently, Mocha is learning about binary system and very interested in bitwise operation.


This day, Mocha got a sequence aa of length nn. In each operation, she can select an arbitrary interval [l,r][l,r] and for all values ii (0≤i≤r−l0≤i≤r−l), replace al+ial+i with al+i&ar−ial+i&ar−i at the same time, where && denotes the bitwise AND operation. This operation can be performed any number of times.


For example, if n=5n=5, the array is [a1,a2,a3,a4,a5][a1,a2,a3,a4,a5], and Mocha selects the interval [2,5][2,5], then the new array is [a1,a2&a5,a3&a4,a4&a3,a5&a2][a1,a2&a5,a3&a4,a4&a3,a5&a2].


Now Mocha wants to minimize the maximum value in the sequence. As her best friend, can you help her to get the answer?


Input


Each test contains multiple test cases.


The first line contains a single integer tt (1≤t≤1001≤t≤100) — the number of test cases. Each test case consists of two lines.


The first line of each test case contains a single integer nn (1≤n≤1001≤n≤100) — the length of the sequence.


The second line of each test case contains nn integers a1,a2,…,ana1,a2,…,an (0≤ai≤1090≤ai≤109).


Output


For each test case, print one integer — the minimal value of the maximum value in the sequence.


Example


input

Copy

4

2

1 2

3

1 1 3

4

3 11 3 7

5

11 7 15 3 7


output

Copy

0

1

3

3


Note


In the first test case, Mocha can choose the interval [1,2][1,2], then the sequence becomes [0,0][0,0], where the first element is 1&21&2, and the second element is 2&12&1.


In the second test case, Mocha can choose the interval [1,3][1,3], then the sequence becomes [1,1,1][1,1,1], where the first element is 1&31&3, the second element is 1&11&1, and the third element is 3&13&1.


题意分析,就是全部&;

 

#include <bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
typedef long long ll;
int a[maxn],b[maxn];
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        int ans=a[0];
        for(int i=0;i<n;i++)
            ans&=a[i];
        printf("%d\n",ans);
    }
    return 0;
}
相关文章
|
5月前
|
机器学习/深度学习 敏捷开发 人工智能
2025产品需求管理最佳实践:从流程优化到工具选型 详解项目需求管理实战
本文深入探讨产品需求管理的核心概念与全流程优化方法,涵盖需求采集、分析、优先级排序及落地实现等关键环节。通过多维度需求采集、科学评估与敏捷迭代,结合团队角色分工,确保需求价值最大化。同时对比评测板栗看板、Jira、Axosoft等管理工具,并展望AI赋能下的智能生成、预测性分析与自动化流程新趋势,助力企业精准把握市场动态,打造爆款产品。掌握需求管理精髓,是产品成功的关键驱动力。
|
10月前
|
敏捷开发 人工智能 JavaScript
Figma-Low-Code:快速将Figma设计转换为Vue.js应用,支持低代码渲染、数据绑定
Figma-Low-Code 是一个开源项目,能够直接将 Figma 设计转换为 Vue.js 应用程序,减少设计师与开发者之间的交接时间,支持低代码渲染和数据绑定。
679 3
Figma-Low-Code:快速将Figma设计转换为Vue.js应用,支持低代码渲染、数据绑定
|
数据采集 数据可视化 数据处理
我们来看一个简单的`matplotlib`代码示例,它使用`plot()`和`scatter()`函数来绘制二维图形。
我们来看一个简单的`matplotlib`代码示例,它使用`plot()`和`scatter()`函数来绘制二维图形。
|
搜索推荐 算法
2022-10-31-基于用户的协同过滤推荐算法实现+MAE+RMSE的求解+项目代码+运行结果图(一)
2022-10-31-基于用户的协同过滤推荐算法实现+MAE+RMSE的求解+项目代码+运行结果图
295 0
|
前端开发 JavaScript 安全
一个很简单理解的轻量级状态管理
本文适合对状态管理感兴趣的小伙伴阅读。
一个很简单理解的轻量级状态管理
|
关系型数据库 MySQL Linux
CentOS7.3部署Mysql8.0.27全过程,RPM包安装各种坑的处理
CentOS7.3部署Mysql8.0.27全过程,RPM包安装各种坑的处理
1082 0
CentOS7.3部署Mysql8.0.27全过程,RPM包安装各种坑的处理
|
算法 测试技术 iOS开发
【第三篇】XiaoZaiMultiAutoAiDevices之运行流程
本框架大部分代码都是有详细的注释,配合此教程系列,把流程梳理通应该是没有什么问题。
184 0
【第三篇】XiaoZaiMultiAutoAiDevices之运行流程
|
3天前
|
云安全 人工智能 安全
AI被攻击怎么办?
阿里云提供 AI 全栈安全能力,其中对网络攻击的主动识别、智能阻断与快速响应构成其核心防线,依托原生安全防护为客户筑牢免疫屏障。