-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfeb9q2.cpp
More file actions
48 lines (44 loc) · 932 Bytes
/
Copy pathfeb9q2.cpp
File metadata and controls
48 lines (44 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
using namespace std;
/* int prod(int arr[], int init, int n)
{
int prod_end = 1;
for (int i = init; i < n; i++)
{
prod_end = prod_end * arr[i];
}
return prod_end;
} */
int main()
{
int samples;
cin >> samples;
while (samples--)
{
int n;
cin >> n;
int arr[n];
int productt=1,prod_end=1,prod_start=1;
bool flag=true;
for (int i = 0; i < n; i++)
{
cin>>arr[i];
productt*=arr[i];
}
//cout<<prod_end<<endl;
for (int i = 0; i < n; i++)
{
prod_start=prod_start*arr[i];
prod_end=productt/prod_start;
if (prod_start==prod_end)
{
cout<<i+1<<endl;
flag=false;
break;
}
}
if(flag){
cout<<-1<<endl;
}
}
}