You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.4 KiB

#include <bits/stdc++.h>
using namespace std;
//24点
int main() {
int a, b, c, d;
cin >> a >> b >> c >> d;
int res = 0, x;
x = a + b + c + d;
if (x == 24) res++;
x = a + b + c - d;
if (x == 24) res++;
x = a + b + c * d;
if (x == 24) res++;
x = a + b - c + d;
if (x == 24) res++;
x = a + b - c - d;
if (x == 24) res++;
x = a + b - c * d;
if (x == 24) res++;
x = a + b * c + d;
if (x == 24) res++;
x = a + b * c - d;
if (x == 24) res++;
x = a + b * c * d;
if (x == 24) res++;
x = a - b + c + d;
if (x == 24) res++;
x = a - b + c - d;
if (x == 24) res++;
x = a - b + c * d;
if (x == 24) res++;
x = a - b - c + d;
if (x == 24) res++;
x = a - b - c - d;
if (x == 24) res++;
x = a - b - c * d;
if (x == 24) res++;
x = a - b * c + d;
if (x == 24) res++;
x = a - b * c - d;
if (x == 24) res++;
x = a - b * c * d;
if (x == 24) res++;
x = a * b + c + d;
if (x == 24) res++;
x = a * b + c - d;
if (x == 24) res++;
x = a * b + c * d;
if (x == 24) res++;
x = a * b - c + d;
if (x == 24) res++;
x = a * b - c - d;
if (x == 24) res++;
x = a * b - c * d;
if (x == 24) res++;
x = a * b * c + d;
if (x == 24) res++;
x = a * b * c - d;
if (x == 24) res++;
x = a * b * c * d;
if (x == 24) res++;
cout << res;
return 0;
}