被翻译暴打

A - 签到题1

You are given a sequence a_1, a_2, \ldots, a_na1,a2,…,an. Each element of aa is 11 or 22.

Find out if an integer kk exists so that the following conditions are met.

  • 1 \leq k \leq n-11≤kn−1, and

  • a_1 \cdot a_2 \cdot \ldots \cdot a_k = a_{k+1} \cdot a_{k+2} \cdot \ldots \cdot a_na1⋅a2⋅…⋅ak=ak+1⋅ak+2⋅…⋅an.

If there exist multiple kk that satisfy the given condition, print the smallest.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1 \le t \le 1001≤t≤100). Description of the test cases follows.

The first line of each test case contains one integer nn (2 \leq n \leq 10002≤n≤1000).

The second line of each test case contains nn integers a_1, a_2, \ldots, a_na1,a2,…,an (1 \leq a_i \leq 21≤ai≤2).

Output

For each test case, if there is no such kk, print -1−1.

Otherwise, print the smallest possible kk.

Sample 1

Inputcopy

Outputcopy

3

6

2 2 1 2 1 2

3

1 2 1

4

1 1 1 1

2

-1

1

Note

For the first test case, k=2k=2 satisfies the condition since a_1 \cdot a_2 = a_3 \cdot a_4 \cdot a_5 \cdot a_6 = 4a1⋅a2=a3⋅a4⋅a5⋅a6=4. k=3k=3 also satisfies the given condition, but the smallest should be printed.

For the second test case, there is no kk that satisfies a_1 \cdot a_2 \cdot \ldots \cdot a_k = a_{k+1} \cdot a_{k+2} \cdot \ldots \cdot a_na1⋅a2⋅…⋅ak=ak+1⋅ak+2⋅…⋅an

For the third test case, k=1k=1, 22, and 33 satisfy the given condition, so the answer is 11.

题目理解:我这个破翻译!!!最开始他翻译出来,就是

a1+a2+。。。。+ak=ak+a(k+1)+。。。+an

然后我就按照这个去做,一直错一直错!!!然后我就问别人我这怎么错了!!!,别人问我全加起来干嘛!!!我一整个傻住!!!然后就是才发现它是相乘啊!!!!!

然后就是相乘嘛,第一次暴力交上去,错了,数据存不了这么大的,然后我就想着记录2的个数,因为1乘起来还是不变的嘛

#include <stdio.h>
int main()
{
    int i,j;
    int a[1001],b[1001],c[1001],d[1001];
    int t,n;
    scanf("%d",&t);
    while(t--)
    {
        int ans=0,sum=0,teap=0;
        scanf("%d",&n);
        for(i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            b[i]=c[i]=0;
        }
        b[0]=c[n+1]=0;
        for(i=1;i<=n;i++)
        {
            if(a[i]==2)
            {
                ans++;
            }
            b[i]=ans;
            //printf("%d ",b[i]);
        }
        //printf("\n");
        for(i=n,j=1;i>=1;j++,i--)
        {
            if(a[i]==2) sum++;
            c[i]=sum;
            d[j]=c[i];
            //printf("%d ",c[i]);
        }
        //printf("\n");
        for(i=1,j=n;i<=n;j--,i++)
        {
            //printf("%d %d %d %d\n",i,j,b[i],c[j]);
            if(b[i]==c[i+1])
            {
                printf("%d\n",i);
                teap=1;
                break;
            }
        }
        if(teap==0)
        {
            printf("-1\n");
        }
    }
}

撤了撤了,这个翻译气死我了!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值