forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathF.cpp
More file actions
45 lines (42 loc) · 872 Bytes
/
F.cpp
File metadata and controls
45 lines (42 loc) · 872 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
#include <bits/stdc++.h>
using namespace std;
string toStr(int x)
{
string s = "";
while (x)
{
s += char(x % 10 + '0');
x /= 10;
}
reverse(s.begin(), s.end());
return s;
}
string getTerm(int x, int y)
{
string xTerm = "x" + toStr(x);
string yTerm = "y" + toStr(y);
if (!y) return xTerm + "|" + xTerm;
if (!x) return yTerm + "|" + yTerm;
return xTerm + "|" + yTerm;
}
int main()
{
freopen("merge.in", "r", stdin);
freopen("merge.out", "w", stdout);
int m, n;
string s[44];
cin >> m >> n;
for (int i = 1; i <= m + n; i++)
{
string s = "";
for (int x = 0; x <= m; x++)
{
int y = i - x;
if (y < 0 || y > n) continue;
string term = getTerm(x, y);
if (s == "") s += term;
else s = "(" + s + ")&(" + term + ")";
}
cout << s << endl;
}
}