题意:

枚举23点,注意,数字也是可以枚举的,wa了一次

#include<stdio.h>
#include<iostream>
#include<sstream>
#include<queue>
#include<map>
#include<memory.h>
#include <math.h>
#include<time.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
#define N 12
int vis[N];
int a[N];
int b[N];
int n;
int final = ; void dfs(int cur, int total)
{
if(cur == && total == )
{
final = ;
return;
}
for(int i = ; i < && !final; i++)
{
if(vis[i])
continue; vis[i] = ;
if(cur != )
{
dfs(cur + , total - a[i]);
dfs(cur + , total + a[i]);
dfs(cur + , total * a[i]);
}
else
{
dfs(cur + , a[i]);
}
vis[i] = ;
} }
int main(const int argc, char** argv)
{
freopen("d:\\1.txt", "r", stdin);
while (scanf("%d %d %d %d %d", a, a + , a + , a + , a + ))
{
if(a[] || a[] || a[] || a[])
{
final = ;
memset(vis, , sizeof(vis));
dfs(, );
if(final)
cout << "Possible" << endl;
else
cout << "Impossible" << endl; }
else
{
return ;
}
}
return ;
}

uva-10344的更多相关文章

  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 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  4. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  5. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  6. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

  7. UVA计数方法练习[3]

    UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...

  8. UVA数学入门训练Round1[6]

    UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include &l ...

  9. UVA - 1625 Color Length[序列DP 代价计算技巧]

    UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这 ...

  10. UVA - 10375 Choose and divide[唯一分解定理]

    UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

随机推荐

  1. 利用asynchttpclient开源项目来把数据提交给服务器

    可以通过github去查找asynchttpclient,并下载源代码,并加载到自己的工程中. 1.利用get方法提交 2.利用post方法来提交

  2. CTF之猪圈密码

    猪圈密码又称济会密码,朱高密码,是一种简单的替代密码,所以安全性很低

  3. 一张方便的graphql schema 语言手册

    参考资料 https://github.com/sogko/graphql-schema-language-cheat-sheet        

  4. A glance at C# vNext

    Contents Introduction Background A list of features Primary constructor Read only auto-properties St ...

  5. mysql增删查改和alter

    盗用两篇文章吧,因为觉得别人总结的已经够好了 http://blog.csdn.net/evankaka/article/details/45580845 http://www.blogjava.ne ...

  6. 升级CentOS 7.4内核版本的三种方案

    https://blog.csdn.net/breeze915/article/details/79243673 在实验环境下,已安装了最新的CentOS 7.4操作系统,现在需要升级内核版本. 实验 ...

  7. [CLPR] 卷积还是相关? - Opencv之filter2D探究

    I am doing something about convolving images in Python and for sake of speed I chose opencv 2.4.9. O ...

  8. nginx 各参数说明

    nginx 各参数说明: 参数 所在上下文 含义

  9. nginx 官方docker镜像使用教程

    最近在看nignx,在本地虚拟机使用docker nginx镜像搭建了nginx+php环境 整理的教程如下: 拉取nginx镜像docker pull nginx 创建一个容器,并挂载本地目录doc ...

  10. <<APUE>> 编译方法

    /********************************************************************************第0种-最简单实用********** ...