-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8.cpp
More file actions
75 lines (48 loc) · 946 Bytes
/
8.cpp
File metadata and controls
75 lines (48 loc) · 946 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<iostream>
#include<cstdio>
#include<stdlib.h>
using namespace std;
int main()
{
int ma=1,ne=1;
int i,j,t,n,k;
int *arr;
char c;
cin>>t;
while(t--)
{
cin>>n;
cin>>k;
ma=1;
ne=1;
arr=new int[n+1];
for(i=1;i<=n;i++)
{
cin>>c;
arr[i]=c-'0';
}
for(i=1;i<=k;i++)
ma*=arr[i];
ne=ma;
for(i=1;i<=n-k;)
{
if(arr[i]==0)
{
ne=1;
for(j=i+1;j<=k+i;j++)
ne*=arr[j];
}
if(arr[i]!=0)
{
ne/=arr[i];
ne*=arr[i+k];
}
if(ne>ma)
ma=ne;
i+=1;
}
cout<<ma<<endl;
delete arr;
}
return 0;
}