nyoj 43 24 Point game

24 Point game

时间限制:3000 ms  |            内存限制:65535 KB

难度:5

描述

There is a game which is called 24 Point game.

In this game , you will be given some numbers. Your task is to find an expression which have all the given numbers and the value of the expression should be 24 .The expression mustn‘t have any other operator except plus,minus,multiply,divide and the brackets.

e.g. If the numbers you are given is "3 3 8 8", you can give "8/(3-8/3)" as an answer. All the numbers should be used and the bracktes can be nested.

Your task in this problem is only to judge whether the given numbers can be used to find a expression whose value is the given number。

输入
The input has multicases and each case contains one line The first line of the input is an non-negative integer C(C<=100),which indicates the number of the cases. Each line has some integers,the first integer M(0<=M<=5) is the total number of the given numbers to consist the expression,the second integers N(0<=N<=100) is the number which the value of the expression should be. Then,the followed M integer is the given numbers. All the given numbers is non-negative and less than 100
输出
For each test-cases,output "Yes" if there is  an expression which fit all the demands,otherwise output "No" instead.
样例输入
2
4 24 3 3 8 8
3 24 8 3 3
样例输出
Yes
No
时间: 2024-10-19 15:40:17

nyoj 43 24 Point game的相关文章

nyoj 43 24 Point game(dfs暴力)

描述 There is a game which is called 24 Point game. In this game , you will be given some numbers. Your task is to find an expression which have all the given numbers and the value of the expression should be 24 .The expression mustn't have any other o

Nyoj 43 24 Point game 【DFS】

24 Point game 时间限制:3000 ms  |  内存限制:65535 KB 难度:5 描述 There is a game which is called 24 Point game. In this game , you will be given some numbers. Your task is to find an expression which have all the given numbers and the value of the expression sho

DFS [NYOJ 43] 24 Point game

24 Point game 时间限制:3000 ms  |  内存限制:65535 KB 难度:5 描述 There is a game which is called 24 Point game. In this game , you will be given some numbers. Your task is to find an expression which have all the given numbers and the value of the expression sho

深搜 nyoj 43 24 Point game

24 Point game 时间限制:3000 ms  |  内存限制:65535 KB 难度:5 描述 There is a game which is called 24 Point game. In this game , you will be given some numbers. Your task is to find an expression which have all the given numbers and the value of the expression sho

电影功夫熊猫使用的单词分析

你英语四级过了吗?功夫熊猫看了吗?功夫熊猫使用了995个英语单词,你会说很简单吧,别急,我给你分析一下,这些单词中有236个单词不在四级词汇范围内,花两分钟时间看看你是否认识这些单词,单词后面跟的数字表示该单词在电影中出现的次数. 你也可以获取本文的分析程序,这样你就可以分析其他电影了.看一部电影之前,先通过这种方式分析一下,然后学习自己不认识的单词,然后再去看电影,如此这样坚持下去,英语水平就会有很大的提升. words(995): 1. you 2492. the 1893. i 1844.

hdu2204 Eddy&#39;s爱好 打表+容斥原理

Ignatius 喜欢收集蝴蝶标本和邮票,但是Eddy的爱好很特别,他对数字比较感兴趣,他曾经一度沉迷于素数,而现在他对于一些新的特殊数比较有兴趣.这些特殊数是这样的:这些数都能表示成M^K,M和K是正整数且K>1.正当他再度沉迷的时候,他发现不知道什么时候才能知道这样的数字的数量,因此他又求助于你这位聪明的程序员,请你帮他用程序解决这个问题.为了简化,问题是这样的:给你一个正整数N,确定在1到N之间有多少个可以表示成M^K(K>1)的数. 打表+容斥原理 1 #include<stdi

java中的拷贝(二)深克隆

浅拷贝(Object类中的clone()方法)是指在拷贝对象时,对于基本数据类型的变量会重新复制一份,而对于引用类型的变量只是对引用进行拷贝. 深拷贝(或叫深克隆) 则是对对象及该对象关联的对象内容,都会进行一份拷贝. 实体类: package com.lin.test; import java.io.Serializable; /** * @athor tianlin * * 2015年6月28日 下午1:56:18 * **/ public class Dog implements Seri

python-day5-格式化输入

python格式化输入包含'%'调用,及format方法 使用‘%’进行格式化输出 1 #最简单的字符串传参 2 tpl='i am %s '%'alex' 3 >>>i am alex 4 5 #字符串与整数传参 6 tpl = 'i am %s age %d'%('alex',18) 7 >>>i am alex age 18 8 9 #字典的传参 10 tpl = 'i am %(name)s age %(age)d'%{'name':'alex','age':1

oracle linux6操作系统oracle11.2.0.4数据库从一台主机A(ora11g)到另一台主机B(ora02)的迁移过程

oracle linux6操作系统oracle11.2.0.4数据库从一台主机A(ora11g)到另一台主机B(ora02)的迁移过程 A生成pfile文件并关闭数据库 [[email protected] ~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.4.0 Production on Fri Jan 1 17:25:12 2016 Copyright (c) 1982, 2013, Oracle.  All rights reserved. SQL>