题目例如以下:

Problem I

23 Out of 5

Input: standard input

Output: standardoutput

Time Limit: 1 second

Memory Limit: 32 MB

Your task is to writea program that can decide whether you can find an arithmetic expression consistingof five given numbers
(1<=i<=5) that will yieldthe value 23.

For this problem we will only consider arithmetic expressions of the followingfrom:

 
where : {1,2,3,4,5} -> {1,2,3,4,5} is a bijective function
and  {+,-,*} (1<=i<=4)

Input

The Input consists of 5-Tupelsof positive Integers, each between 1 and 50.

Input is terminated by a line containing five zero's. This line should not beprocessed.

Output

For each 5-Tupel print"Possible" (without quotes) if their exists an arithmetic expression(as described above) that yields 23. Otherwise print "Impossible".

Sample Input

1 1 1 1 1
1 2 3 4 5
2 3 5 7 11
0 0 0 0 0

Sample Output

Impossible
Possible
Possible

也是直接回溯就能够了,只是要注意π是个双射函数(bijective function)。所以要一一相应。不能反复使用,採用一个vis数组标记就可以。

AC的代码例如以下:

UVA 23 out of 5的更多相关文章

  1. uva 10344 23 out of 5 凑运算结果 全排列+dfs

    五个数三个运算符号,排列之后凑成结果为23,不考虑优先级. 很水,数据量也不大,先生成五个数的全排列,用dfs找出结果能否为23即可. 代码: #include <cstdio> #inc ...

  2. uva10344 23 out of 5

    Your task is to write a program that can decide whether you can nd an arithmetic expression consisti ...

  3. UVA 11427 (概率DP+期望)

    题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35396 题目大意:每晚打游戏.每晚中,赢一局概率p,最多玩n局, ...

  4. UVa 103 - Stacking Boxes(dp求解)

    题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...

  5. UVA 437 十九 The Tower of Babylon

    The Tower of Babylon Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Subm ...

  6. UVa 1593代码对齐

    原题链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  7. UVA 10905 Children's Game 孩子的游戏 贪心

    题意:给出N个数,要求把它们拼凑起来,让得到的数值是最大的. 只要分别比较两个数放前与放后的值的大小,排序后输出就可以了. 比如123和56,就比较12356和56123的大小就行了. 写一个比较函数 ...

  8. UVa 10012 - How Big Is It? 堆球问题 全排列+坐标模拟 数据

    题意:给出几个圆的半径,贴着底下排放在一个长方形里面,求出如何摆放能使长方形底下长度最短. 由于球的个数不会超过8, 所以用全排列一个一个计算底下的长度,然后记录最短就行了. 全排列用next_per ...

  9. Uva 11549 - Calculator Conundrum 找规律加map

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

随机推荐

  1. Python基础语法(转)

    作者:Peter 出处:http://www.cnblogs.com/Peter-Zhang/   Python 基础语法(一) Python的特点 1. 简单 Python是一种代表简单思想的语言. ...

  2. Android Bitmap转换WebP图片导致损坏的分析及解决方案

    背景 作为移动领域所力推的图片格式,WebP图片在商业领域证明了其应有的价值.基于其他格式的横向对比,其在压缩性能表现,及还原度极为优秀,节省大量的带宽开销.基于可观的效益比,团队早前已开始磋商将当前 ...

  3. 联想 Z5 Pro(L78031)免解锁BL 免rec 保留数据 ROOT Magisk Xposed 救砖ZUI 10.0.355

    >>>重点介绍<<< 第一:本刷机包可卡刷可线刷,刷机包比较大的原因是采用同时兼容卡刷和线刷的格式,所以比较大第二:[卡刷方法]卡刷不要解压刷机包,直接传入手机后用 ...

  4. ubuntu部署java环境

    一.安装java sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracl ...

  5. canvas一周一练 -- canvas绘制太极图(6)

    运行效果: <!DOCTYPE html> <html> <head> </head> <body> <canvas id=" ...

  6. Linux的net.ipv4.tcp_timestamps参数

    Q1 今天发生了一个奇怪的现象,在家里始终打开公司的网站打开不了,我就齐了怪了,然后我就各种测试,从ping到dig域名,然后再curl,都是没有问题的,但是就是打不开,最好没有办法只能抓包了,从抓包 ...

  7. 经典书籍---MySQL经典书籍下载

    以下是一些经典的MySQL书籍电子版,括号内为提取码,若需自取. 欢迎阅读纸质版,尊重作者版权 高性能MySQL_中文版 [ hre3 ] 高性能MySQL_英文版[ m2xj ] MySQL技术内幕 ...

  8. <MySQL>入门六 变量

    /* 变量 系统变量: 全局变量 会话变量 自定义变量 用户变量 局部变量 */ -- ------------系统变量-------------------- /* 变量由系统提供,不是用户定义,属 ...

  9. Window下的———TOMCAT环境的配置

    1. 先去官方网站下载需要的猫(tomcat) http://tomcat.apache.org/ 2.下载好包,然后解压出来,放在你需要的位置上 3.去到配环境变量的地方,进行相应的环境配置     ...

  10. keep

    简介 什么是keepalived呢?keepalived是实现高可用的一种轻量级的技术手段,主要用来防止单点故障(单点故障是指一旦某一点出现故障就会导致整个系统架构的不可用)的发生.之所以说keepa ...