-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
69 lines (66 loc) · 1.23 KB
/
test.cpp
File metadata and controls
69 lines (66 loc) · 1.23 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
58
59
60
61
62
63
64
65
66
67
68
69
#include<bits/stdc++.h>
using namespace std;
int main(){
// for(int i=1;i<100;i++){
// if(7*i > 4+i){
// cout<<i<<endl;
// }
// }
int t;
cin>>t;
while(t--){
int n;
cin>>n;
vector<int> v(n);
vector<int> ans;
for(int i=0;i<n;i++){
cin>>v[i];
}
ans.push_back(1);
// int sum=1;
for(int i=1;i<n-1;i++){
ans.push_back(v[i-1]*ans[i-1] + 1);
}
for(int i=1;i<1e8;i++){
if(v[n-1]*i > ans[n-2] + i){
ans.push_back(i);
break;
}
}
// for(int i=2;i<1e8;i++){
// if(v[0]*i > ans[n-1] + i - 1){
// // ans.push_back(i);
// ans[0]=i;
// break;
// }
// }
// for(int i=1;i<1e8;i++){
// if(v[0]*i > ans[0] + i){
// ans.push_back(i);
// break;
// }
// }
int sum=0;
for(int i=0;i<n;i++){
sum+=ans[i];
}
bool b= true;
// cout<<sum<<endl;
for(int i=0;i<n;i++){
if(v[i]*ans[i] < sum){
b = true;
break;
}
}
if(b){
for(int i=0;i<n;i++){
cout<<ans[i]<<" ";
}
cout<<endl;
}else{
cout<<-1<<endl;
}
// cout<<endl;
}
return 0;
}