Files
python/TangDou/LanQiaoBei/LanQiao12XuanBaSai/4.cpp

67 lines
1.5 KiB
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#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;
}