-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodetogether.cpp
More file actions
47 lines (47 loc) · 955 Bytes
/
codetogether.cpp
File metadata and controls
47 lines (47 loc) · 955 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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
for(int i=1;i<=t;i++)
{
int n,m;
cin>>n>>m;
long long int g[n],l[n],mod[m];
for(int j=0;j<n;j++)
{
cin>>g[j];
}
for(int j=0;j<n;j++)
{
cin>>l[j];
}
for(int j=0;j<m;j++)
{
cin>>mod[j];
}
int compare=1;
label:
int j=0,product=1,max=-1;
while(j<n && compare<=m)
{
if(g[j]==compare)
{
product*=l[j];
if(product%mod[compare-1]>max)
{
max=product%mod[compare-1];
}
}
j++;
}
cout<<max<<" ";
if(compare<m)
{
compare++;
goto label;
}
cout<<endl;
}
}