设为首页 加入收藏

TOP

CSU1600:Twenty-four point(DFS)
2015-11-21 01:03:14 来源: 作者: 【 】 浏览:1
Tags:CSU1600:Twenty-four point DFS

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


题意:四个数字,通过四则运算看能不能得到24点
思路:对于如此小量的数,直接暴搜,你不需要怀疑人生
#include 
  
    
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include
        #include 
        
          #include 
         
           #include 
          
            #include 
           
             using namespace std; #define ls 2*i #define rs 2*i+1 #define up(i,x,y) for(i=x;i<=y;i++) #define down(i,x,y) for(i=x;i>=y;i--) #define mem(a,x) memset(a,x,sizeof(a)) #define w(a) while(a) #define LL long long const double pi = acos(-1.0); #define Len 200005 #define mod 19999997 const int INF = 0x3f3f3f3f; #define exp 1e-8 double a[5]; bool dfs(double *a,int n) { if(n==1) return fabs(a[0]-24)
             
            
           
          
         
        
      
     
    
   
  
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇[LeetCode] Combination Sum 下一篇C++中求数组连续子向量的最大和(..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: