A - Spy Detected

1. Problem

You are given an array aa consisting of nn (n \ge 3n≥3) positive integers. It is known that in this array, all the numbers except one are the same (for example, in the array [4, 11, 4, 4][4,11,4,4] all numbers except one are equal to 44).

Print the index of the element that does not equal others. The numbers in the array are numbered from one.

Input

The first line contains a single integer t(1≤t≤100). Then t test cases follow.

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

The second line of each test case contains n integers a1​,a2​,…,an​ (1≤ai​≤100).

It is guaranteed that all the numbers except one in the aa array are the same.

Output

For each test case, output a single integer — the index of the element that is not equal to others.

Example

input

4
4
11 13 11 11
5
1 4 4 4 4
10
3 3 3 3 10 3 3 3 3 3
3
20 20 10

output

2
1
5
3

2. Accepted Code

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int judge(int x, int y, int z);
    int t;
    scanf("%d", &t);
    while(t--)
    {
        int n;
        scanf("%d", &n);
        int arr[n];
        int i;
        int flag=0;
        for(i=0; i<n; i++)
        {
            scanf("%d", &arr[i]);
            if(i>=2 && !flag)
            {
                int num = judge(arr[i-2], arr[i-1], arr[i]);
                if(num){
                    if(arr[i-2]==num) printf("%d\n", i-2+1);
                    else if(arr[i-1]==num) printf("%d\n", i-1+1);
                    else printf("%d\n", i+1);
                    flag++;
                }
            }
        }
    }
    return 0;
}
int judge(int x, int y, int z)
{
    //判断并找出三个数中不同的那个
    if(x-y==0&&x-z==0)
    {
        return 0;
    }
    else
    {
        return x==y?z:(x==z?y:x);
    }
}

猜你喜欢

转载自blog.csdn.net/CH_whale/article/details/121442286