-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSA02002.cpp
More file actions
55 lines (50 loc) · 897 Bytes
/
DSA02002.cpp
File metadata and controls
55 lines (50 loc) · 897 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
#include<bits/stdc++.h>
using namespace std;
vector<int> a;
vector<int> b;
vector<vector<int>> v;
int n;
void Try(int i)
{
v.push_back(a);
if(i == n)
{
return;
}
for(int j = 0; j<a.size()-1; j++)
{
b.push_back(a[j] + a[j+1]);
}
a = b;
b.clear();
Try(i+1);
}
int main()
{
int t;
cin >> t;
while(t--)
{
a.clear();
b.clear();
v.clear();
cin >> n;
a.resize(n);
for(int& i : a) cin >> i;
Try(1);
reverse(v.begin(), v.end());
for(auto i: v)
{
cout << "[";
for(int j = 0; j<i.size(); j++)
{
cout << i[j];
if(j!= i.size()-1)
cout << ' ';
else
cout << "] ";
}
}
cout << endl;
}
}