Twenty-fourpoint
来源:互联网 发布:淘宝运营培训班有用吗 编辑:程序博客网 时间:2024/05/16 23:55
#include <iostream>#include <algorithm>#include <queue>#include <cstring>#include <cstdio>#include <vector>#include <string>#include <iterator>#include <cmath>#include <deque>#include <stack>#include <cctype>#include <iomanip>using namespace std;typedef long long ll;typedef long double ld;const int N = 1100;const int INF = 0xfffffff;const double EPS = 1e-8;const ll MOD = 1e9 + 7;const ld PI = acos (-1.0);#define INFL 0x7fffffffffffffffLL#define met(a, b) memset(a, b, sizeof(a))#define put(a) cout << setiosflags(ios::fixed) << setprecision(a)double a[5];bool dfs (double *a, int n);int main (){ while (cin >> a[0] >> a[1] >> a[2] >> a[3]) { if (dfs (a, 4)) puts("Yes"); else puts("No"); } return 0;}bool dfs (double *a, int n){ double tmp[5]; if (n == 1) return fabs(a[0] - 24 ) < EPS; for (int i=0; i<n; i++) { for (int j=i; j<n; j++) { if (i == j) continue; int len = 0; for (int k=0; k<n; k++) { if (k != i && k != j) tmp[len++] = a[k]; } tmp[len] = a[i] + a[j]; if (dfs(tmp, n - 1)) return true; tmp[len] = a[i] - a[j]; if (dfs (tmp, n - 1)) return true; tmp[len] = a[j] - a[i]; if (dfs (tmp, n - 1)) return true; tmp[len] = a[i] * a[j]; if (dfs (tmp, n - 1)) return true; if (a[i] != 0) { tmp[len] = a[j] / a[i]; if (dfs (tmp, n - 1)) return true; } if (a[j] != 0) { tmp[len] = a[i] / a[j]; if (dfs(tmp, n - 1)) return true; } } } return false;}
0 0
- Twenty-fourpoint
- Twenty-four
- 我的twenty five
- HOJ 1610 Twenty Questions
- UVALive 4643 Twenty Questions
- UVA 1252 Twenty Questions
- UVALive - 4643 Twenty Questions
- POJ-3809-Twenty Questions
- Trainmaster One Hundred Twenty
- UVa1252 Twenty Questions
- uva1252 Twenty Questions
- UVALive 4643 Twenty Questions
- csu1600: Twenty-four point
- UVa 1252 Twenty Questions
- 1252 - Twenty Questions
- UVa1252 - Twenty Questions
- A. Again Twenty Five
- A. Again Twenty Five!
- 如何制作网站地图(sitemap.html和sitemap.xml)?
- 定位
- Java读取Excel并解析文本(并格式化输出)
- TabHost详解
- ace admin java 后台源码
- Twenty-fourpoint
- 浮动特点及相关问题
- Android开发之AsyncTAsk的用法
- 2014年计算机求职总结--准备篇
- HUFFMAN编码进行压缩---【数据结构】
- linux查看端口使用情况
- Working with Visual Aids in Public Speeches
- struts2学习笔记之七(常量)
- C语言实现文件字符替换