-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathB.cpp
42 lines (40 loc) · 755 Bytes
/
B.cpp
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
#include <bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<ctype.h>
#define lli long long int
#define mod 1000003
#define pi 3.141592653589793238
using namespace std;
int main()
{ int t;
cin>>t;
while(t--)
{ int n;
cin>>n;
lli a[n],sum=0,b[n],sum1=0,sum2=0;
for(int i=0;i<n;i++)
{ cin>>a[i];
sum+=a[i];
}
for(int i=0;i<n;i++)
b[i]=a[i];
for(int i=0;i<n;i++)
if(i%2==0)
sum1+=b[i];
else
sum2+=b[i];
if(sum1<=sum2)
for(int i=0;i<n;i+=2)
b[i]=1;
else
for(int i=1;i<n;i+=2)
b[i]=1;
for(int i=0;i<n;i++)
cout<<b[i]<<" ";
cout<<endl;
}
return 0;
}