-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSA02001.cpp
More file actions
52 lines (49 loc) · 772 Bytes
/
Copy pathDSA02001.cpp
File metadata and controls
52 lines (49 loc) · 772 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
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int n;
vector<int> a;
vector<int> b;
void print()
{
cout << "[";
for(int i = 0; i<a.size(); i++)
{
cout << a[i];
if(i!= a.size()-1)
cout << ' ';
else
cout << ']';
}
cout << endl;
}
void Try(int i)
{
print();
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()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t;
cin >> t;
while(t--)
{
cin >> n;
a.resize(n);
for(int i = 0; i<n; i++)
{
cin >> a[i];
}
Try(1);
}
}