csu 1600: Twenty-four point
1600: Twenty-four point
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 490 Solved: 78
[Submit][Status][Web Board]
Description
Given four numbers, can you get twenty-four through the addition, subtraction, multiplication, and division? Each number can be used only once.
Input
The input consists of multiple test cases. Each test case contains 4 integers A, B, C, D in a single line (1 <= A, B, C, D <= 13).
Output
For each case, print the “Yes” or “No”. If twenty-four point can be get, print “Yes”, otherwise, print “No”.
Sample Input
2 2 3 9
1 1 1 1
5 5 5 1
Sample Output
Yes
No
Yes
HINT
For the first sample, (2/3+2)*9=24.
Source
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <stack>
#include <cctype>
#include <vector>
#include <cmath>
#include <map>
#include <queue> #define ll long long
#define eps 1e-8 using namespace std; double a[]; int dfs(double p[],int len)
{
if(len==){
if(fabs(p[]-)<eps){
return ;
}
else{
return ;
}
}
double f[];
int cou;
int i,j,k;
for(i = ;i <len-;i++){
for(j=i+;j<len;j++){
cou=;
for(k=;k<len;k++){
if(k!=i && k!=j){
f[cou]=p[k];cou++;
}
}
f[cou]=p[i]+p[j];
if(dfs(f,cou+)) return ;
f[cou]=p[i]-p[j];
if(dfs(f,cou+)) return ;
f[cou]=p[j]-p[i];
if(dfs(f,cou+)) return ;
f[cou]=p[i]*p[j];
if(dfs(f,cou+)) return ;
if(p[j]!=){
f[cou]=p[i]/p[j];
if(dfs(f,cou+)) return ;
}
if(p[i]!=){
f[cou]=p[j]/p[i];
if(dfs(f,cou+)) return ;
}
}
}
return ;
} int main()
{
//freopen("in.txt","r",stdin);
//scanf("%d",&T);
//for(int ccnt=1;ccnt<=T;ccnt++){
while(scanf("%lf%lf%lf%lf",&a[],&a[],&a[],&a[])!=EOF){
if(dfs(a,) == ){
printf("Yes\n");
}
else{
printf("No\n");
}
}
return ;
}
csu 1600: Twenty-four point的更多相关文章
- 我叫Twenty,我是要成为博客王的博客框架
标题套用了路飞的格式,其实我想说的是大多数都不相信你的梦想,直到你快走到了. 不废话了,介绍一下twenty: 这是基于CMS框架 zerojs打造一个博客.zerojs 的架构介绍在这里http:/ ...
- SQL 2008升级SQL 2008 R2完全教程或者10.00.1600升级10.50.1600
http://blog.csdn.net/feng19821209/article/details/8571571 SQL 2008升级SQL 2008 R2完全教程或者10.00.1600升级10. ...
- SQL 2008 R2下载 升级R2 SP1或者SQL 2008从10.50.1600升级10.5.2500
SQL Server 2008 R2 中英文 开发版/企业版/标准版 链接地址 一. 简体中文 1. SQL Server 2008 R2 Developer (x86, x64, ia64) - D ...
- Droidicon – 1600+ 漂亮的 Android 图标
Droidicon 提供超过1600款定制图标,让你可以超级容易的把图标和徽章添加到您的应用程序中.你可以自定义你想要的各种形式的图标,给图标添加描边,透明度和颜色过滤器.包括这些 Google Ma ...
- csu 1812: 三角形和矩形 凸包
传送门:csu 1812: 三角形和矩形 思路:首先,求出三角形的在矩形区域的顶点,矩形在三角形区域的顶点.然后求出所有的交点.这些点构成一个凸包,求凸包面积就OK了. /************** ...
- CSU 1503 点到圆弧的距离(2014湖南省程序设计竞赛A题)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1503 解题报告:分两种情况就可以了,第一种是那个点跟圆心的连线在那段扇形的圆弧范围内,这 ...
- CSU 1120 病毒(DP)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1120 解题报告:dp,用一个串去更新另一个串,递推方程是: if(b[i] > a ...
- CSU 1116 Kingdoms(枚举最小生成树)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1116 解题报告:一个国家有n个城市,有m条路可以修,修每条路要一定的金币,现在这个国家只 ...
- CSU 1113 Updating a Dictionary(map容器应用)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1113 解题报告:输入两个字符串,第一个是原来的字典,第二个是新字典,字典中的元素的格式为 ...
随机推荐
- Load average in Linux的精确含义
Man 上的解释: load average System load averages is the average number of processes that are either in a ...
- 【HEVC帧间预测论文】P1.6 A Fast HEVC Inter CU Selection Method Based on Pyramid Motion Divergence
A Fast HEVC Inter CU Selection Method Based on Pyramid Motion Divergence <HEVC标准介绍.HEVC帧间预测论文笔记&g ...
- SAP成都研究院姚瑶:软件质量保证工作的变迁
大家好,我是来自SAP成都研究院Revenue Cloud 团队的质量工程师 , yoyo.很高兴可以和大家分享我个人的工作体会.每个团队都有QE(Quality Engineer), 相信大家对QE ...
- EOS Dawn 3.0 智能合约 -- 新格式
1.简介 随着EOS Dawn 3.0发布,智能合约的坑又要重新踩了o(╥﹏╥)o:3.0不仅将原来本身就在链里的基础合约独立出来,简单的介绍见3.0合约改变,合约的书写方式也有巨大变化,相比之前更加 ...
- oracle的系统表
-- DBA/ALL/USER/V_$/GV_$/SESSION/INDEX开头的绝大部分都是视图-- DBA_TABLES意为DBA拥有的或可以访问的所有的关系表.-- ALL_TABLES意为某一 ...
- Python3基础教程(十六)—— 迭代器、生成器、装饰器
在这个实验里我们学习迭代器.生成器.装饰器有关知识. 这几个概念是 Python 中不容易理解透彻的概念,务必把所有的实验代码都完整的输入并理解清楚其中每一行的意思. 迭代器 Python 迭代器(I ...
- vue iview render里面 没有双向绑定 renderHeader 要序列化 反序列 一下
vue iview render里面 没有双向绑定 renderHeader 要序列化 反序列 一下 renderHeader: (h, params) => { return [ h('Rad ...
- myBatis.xml文档实例
单个参数:myBatis不会做特殊处理 #{参数名}: 取出参数值 多个参数: myBatis会做特殊处理 多个参数会被封装成一个MAP key:param1 param2.... param10,或 ...
- 使用plsql导入dmp文件缺少imp*.exe
在C:\app\Administrator\product\11.2.0\client_2\BIN 找到imp.exe 导入
- 微信小程序入口场景的问题整理与相关解决方案
前言 最近一段时间都在做小程序. 虽然是第二次开发小程序,但是上次做小程序已经是一年前的事了,所以最终还是被坑得死去活来. 这次是从零开始开发一个小程序,其实除了一些莫名其妙的兼容性问题,大多数坑点都 ...