Uva--10344(暴力)

2014-07-15 12:12:31

题意&思路:不说啥了。

 1 #include <cstdio>
 2 #include <iostream>
 3 #include <cstring>
 4 using namespace std;
 5 
 6 int s[5],flag;
 7 
 8 void Dfs(int cur,int re){
 9     if(cur == 5){
10         printf("%d\n",re);
11         if(re == 23)
12             flag = 1;
13         return;
14     }
15     if(!flag)
16         Dfs(cur + 1,re + s[cur]);
17     if(!flag)
18         Dfs(cur + 1,re - s[cur]);
19     if(!flag)
20         Dfs(cur + 1,re * s[cur]);
21     //if(!flag && re != 0)
22       //  Dfs(cur + 1,re / s[cur]);
23 }
24 int main(){
25     while(scanf("%d %d %d %d %d",&s[0],&s[1],&s[2],&s[3],&s[4]) == 5){
26         flag = 0;
27         Dfs(1,s[0]);
28         if(flag)
29             printf("Possible\n");
30         else
31             printf("Impossible\n");
32     }
33     return 0;
34 }

 

转载于:https://www.cnblogs.com/naturepengchen/articles/3844479.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值