質問編集履歴
1
コード修正追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -91,3 +91,85 @@
|
|
91
91
|
|
92
92
|
|
93
93
|
```
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
#修正後
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
#include <bits/stdc++.h>
|
102
|
+
|
103
|
+
using namespace std;
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
int main() {
|
108
|
+
|
109
|
+
int abcd;
|
110
|
+
|
111
|
+
cin >> abcd;
|
112
|
+
|
113
|
+
vector<int> ticket(4);
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
for(int i = 3; i > -1; i--){
|
118
|
+
|
119
|
+
ticket[i] = (abcd%10); // 1桁取り出していく
|
120
|
+
|
121
|
+
abcd /= 10;
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
for(int bit = 0; bit < (1 << 3); bit++){
|
128
|
+
|
129
|
+
int ans = ticket[0];
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
for(int idx = 0; idx < 3; idx++){
|
134
|
+
|
135
|
+
if(bit & (1 << idx)) ans += ticket[idx + 1];
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
else ans -= ticket[idx + 1];
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
if(ans == 7){
|
146
|
+
|
147
|
+
cout << ticket[0];
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
for(int idx = 0; idx < 3; idx++){
|
152
|
+
|
153
|
+
if(bit & (1 << idx)) cout << '+';
|
154
|
+
|
155
|
+
else cout << '-';
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
cout << ticket[idx + 1];
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
cout << "=7" << endl;
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
```
|