-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaltarray.cpp
More file actions
executable file
·57 lines (52 loc) · 1 KB
/
altarray.cpp
File metadata and controls
executable file
·57 lines (52 loc) · 1 KB
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
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long int
#define pb push_back
#define mk make_pair
#define flp(i, n) for(int i=0; i<n; i++)
int power(int a, int b) {
int x = 1, y = a;
while(b > 0) {
if(b%2 == 1) {
x=(x*y);
if(x>mod) x%=mod;
}
y = (y*y);
if(y>mod) y%=mod;
b /= 2;
}
return x;
}
int totient(int n) {
int result = n;
for(int i=2;i*i <= n;i++)
{
if (n % i == 0) result -= result / i;
while (n % i == 0) n /= i;
}
if (n > 1) result -= result / n;
return result;
}
int32_t main(void)
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
flp(i, n) cin>>a[i];
int dp[n];
flp(i, n) dp[i]=1;
for(int i=n-2; i>=0; i--)
{
if( (a[i]>0 && a[i+1]<0) || (a[i]<0 && a[i+1]>0) )
dp[i]+=dp[i+1];
}
flp(i, n) cout<<dp[i]<<" ";
cout<<"\n";
}
return 0;
}