uva10344 - 23 out of 5
来源:互联网 发布:手机淘宝优惠券在哪里 编辑:程序博客网 时间:2024/05/01 20:05
下面的东西,你知道几个:
1、不同的排列相同的运算符得到的结果不同,
2、在生成排列前必须要排序数据。
好了,对于这个题,也没有什么好说的,直接贴代码把;
代码如下:
#include <cstdio>#include <algorithm>using namespace std;int num[5], possible;void print_product(int cur, int product){ if(possible)return; if(cur==5) { if(product==23&&!possible) {possible = 1; } return;} print_product(cur+1,product+num[cur]); print_product(cur+1,product-num[cur]); print_product(cur+1,product*num[cur]);}int main (){ int sum = 1; while(1) { possible = sum = 0; for(int i = 0; i < 5; i++) {scanf("%d",&num[i]); sum+=num[i];} if(!sum)break; sort(num,num+5); do { print_product(1,num[0]); }while(next_permutation(num,num+5)); if(possible)puts("Possible"); else puts("Impossible"); } return 0;}
- uva10344 - 23 out of 5
- uva10344 - 23 out of 5
- uva10344 23 out of 5
- UVA10344 23 out 5
- 23 Out of 5
- UVA10344----算23点
- UVa10344
- UVA10344
- uva10344
- uva10344
- UVA10344
- UVa10344
- uva10344
- 10344--23 out of 5
- 10344 - 23 out of 5(***)
- 10344 - 23 out of 5
- UVaOJ10344 - 23 out of 5
- 10344 - 23 out of 5
- ※C++随笔※=>☆C++基础☆=>※№浅谈指针与引用
- Notes On <Agile Web Application Development with Yii 1.1 and PHP5> - 01
- IOS程序之间的文件共享
- calabash
- 写给4年前没有开始做设计的自己
- uva10344 - 23 out of 5
- centos 5.3 上安装 emacs 23.2
- Ubuntu 12.04下玩转终端管理器Byobu
- mini2440 裸机编程 - 内存控制
- Android Service学习之IntentService 深入分析
- GitHut上最受关注的Objective-C项目
- 反射
- zk消息处理链
- linux realloc之内存分配