题目

这是传说中的深搜吗。。。。不确定,,,,貌似更加像是模拟,,,,

//我要做深搜题目拉
//实际上还是模拟 #include<iostream>
#include<string>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int ans;
char a[];
__int64 n;
int fuhao[];
int len;
__int64 cal()
{
int fh=;
__int64 num=,tmp=;
tmp=a[]-'';
for(int i=;i<len;i++){
if(fuhao[i-]==){
if(fh==)num+=tmp;
else if(fh==)num-=tmp;
else if(fh==)num=tmp;
tmp=;
fh=;
}
else if(fuhao[i-]==){
if(fh==)num+=tmp;
else if(fh==)num-=tmp;
else if(fh==)num=tmp;
tmp=;
fh=;
}
tmp=tmp*+a[i]-'';
}
if(fh==)num+=tmp;
else if(fh==)num-=tmp;
else num=tmp;
return num;
}
void dfs(int st)
{
if(st==len-){//符号比数少一位
if(cal()==n)ans++;
return;
}
fuhao[st]=;
dfs(st+);
fuhao[st]=;
dfs(st+);
fuhao[st]=;
dfs(st+);
} int main()
{
while(scanf("%s%I64d",a,&n)!=EOF)
{
memset(fuhao,,sizeof(fuhao));
len=strlen(a);
ans=;
dfs();
printf("%d\n",ans);
}
return ;
}

HDU 2266 How Many Equations Can You Find(模拟,深搜)的更多相关文章

  1. HDOJ(HDU).2266 How Many Equations Can You Find (DFS)

    HDOJ(HDU).2266 How Many Equations Can You Find (DFS) [从零开始DFS(9)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零 ...

  2. hdu 4740【模拟+深搜】.cpp

    题意: 给出老虎的起始点.方向和驴的起始点.方向.. 规定老虎和驴都不会走自己走过的方格,并且当没路走的时候,驴会右转,老虎会左转.. 当转了一次还没路走就会停下来.. 问他们有没有可能在某一格相遇. ...

  3. hdu - 2266 How Many Equations Can You Find (简单dfs)

    http://acm.hdu.edu.cn/showproblem.php?pid=2266 给一个字符串和一个数n,在字符串中间可以插入+或者 -,问有多少种等于n的情况. 要注意任意两个数之间都可 ...

  4. HDU 2266 How Many Equations Can You Find(DFS)

    How Many Equations Can You Find Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  5. hdu 2266 dfs+1258

    How Many Equations Can You Find Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 ...

  6. hdu 5648 DZY Loves Math 组合数+深搜(子集法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5648 题意:给定n,m(1<= n,m <= 15,000),求Σgcd(i|j,i&am ...

  7. 深搜基础题目 杭电 HDU 1241

    HDU 1241 是深搜算法的入门题目,递归实现. 原题目传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1241 代码仅供参考,c++实现: #incl ...

  8. (深搜)Oil Deposits -- hdu -- 1241

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=1241 Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  9. hdu 1518 Square(深搜+剪枝)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1518 题目大意:根据题目所给的几条边,来判断是否能构成正方形,一个很好的深搜应用,注意剪枝,以防超时! ...

随机推荐

  1. Linux网络编程——浅谈 TCP 三次握手和四次挥手

    一.tcp协议格式 二.三次握手 在 TCP/IP 协议中.TCP 协议提供可靠的连接服务,採用三次握手建立一个连接. 第一次握手:建立连接时,client发送 syn 包(tcp协议中syn位置1. ...

  2. UVa 642 - Word Amalgamation

    题目:给你一个单词列表.再给你一些新的单词.输出列表中又一次排列能得到此新单词的词. 分析:字符串.对每一个字符串的字母排序生成新的传f(str).总体排序,用二分来查找就可以. 说明:注意输出要满足 ...

  3. poj 1741(树的点分治)

    Tree Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dis ...

  4. 【NOI 2014】 动物园

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=3670 [算法] KMP [代码] #include<bits/stdc++.h ...

  5. 完美解决 linux sublime 中文无法输入

    感谢oschina 中几位前辈的分享 下面是我结合自己的情况所配置的具体步骤: 系统环境: ubuntu 12.10 输入法:fcitx fcitx 安装 apt-get install fcitx ...

  6. poj3071Football(概率期望dp)

    Football Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5620   Accepted: 2868 Descript ...

  7. 记录一下Junit测试MongoDB,获取MongoTemplate

    只是自己记录一下,测试MongoDB帮助类时,没有配置文件的测试 public class HelperTest { MongoTemplate template; @Before public vo ...

  8. [DP专题]悬线法

    参考:https://blog.csdn.net/twtsa/article/details/8120269 先给出题目来源:(洛谷) 1.p1387 最大正方形 2.P1169 棋盘制作 3.p27 ...

  9. jmeter 参数化学习笔记

    上次写了在接口的交互过程中,系统返回的内容,需要在接下来的交互中用到,从而把参数进行参数化的关联,这次写一下在压测过程中,如果每次发起请求参数名相同,单参数值需要替换的,我们需要进行的参数化. 在使用 ...

  10. R - Games

    Problem description Manao works on a sports TV. He's spent much time watching the football games of ...