-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabc079_c.cc
54 lines (49 loc) · 1.83 KB
/
abc079_c.cc
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
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/lexical_cast.hpp>
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)
int _ = (
#ifndef LOCAL
std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
std::cout.precision(10), std::cout.setf(std::ios::fixed));
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;
int main() {
string S;
cin >> S;
vec<int> ABCD;
transform(ALL(S), back_inserter(ABCD),
[](char c) { return boost::lexical_cast<int>(c); });
const int A = ABCD[0];
const int B = ABCD[1];
const int C = ABCD[2];
const int D = ABCD[3];
if (A + B + C + D == 7) {
cout << S[0] << "+" << S[1] << "+" << S[2] << "+" << S[3] << "=7" << endl;
} else if (A + B + C - D == 7) {
cout << S[0] << "+" << S[1] << "+" << S[2] << "-" << S[3] << "=7" << endl;
} else if (A + B - C + D == 7) {
cout << S[0] << "+" << S[1] << "-" << S[2] << "+" << S[3] << "=7" << endl;
} else if (A + B - C - D == 7) {
cout << S[0] << "+" << S[1] << "-" << S[2] << "-" << S[3] << "=7" << endl;
} else if (A - B + C + D == 7) {
cout << S[0] << "-" << S[1] << "+" << S[2] << "+" << S[3] << "=7" << endl;
} else if (A - B + C - D == 7) {
cout << S[0] << "-" << S[1] << "+" << S[2] << "-" << S[3] << "=7" << endl;
} else if (A - B - C + D == 7) {
cout << S[0] << "-" << S[1] << "-" << S[2] << "+" << S[3] << "=7" << endl;
} else if (A - B - C - D == 7) {
cout << S[0] << "-" << S[1] << "-" << S[2] << "-" << S[3] << "=7" << endl;
}
return 0;
}