题目

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

//我要做深搜题目拉
//实际上还是模拟 #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 ;
}

最新文章

  1. node-sass报错解决方法
  2. 配置L2TP IPsec VPN (CentOS 6.5)
  3. phpstrom正则替换
  4. CSDN数据库被爆 统计CSDN用户都喜欢哪些密码
  5. 开发完整的Web项目必备
  6. [SDOI2015]权值
  7. ural 1207 Median on the Plane
  8. phpmyadmin自增字段
  9. MSSQLServer的备份与还原
  10. akoj-1055-矩阵乘法
  11. shapefile添加字段 设置文件名为字段内容
  12. 002_关于six版本过低报cannot import name urllib_parse的问题
  13. @PathVariable与@RequestBody的区别,及前段请求接口的写法。
  14. github 多人协作
  15. C# 中的浅表副本与深表副本
  16. 简述项目中优化sql语句执行效率的方法,从哪些方面,sql语句性能如何分析?
  17. R语言外部数据读取
  18. Struts 2 Tutorial
  19. Kotlin in Action 笔记
  20. 20155234 2016-2017-2 《Java程序设计》第8周学习总结

热门文章

  1. Python获取当前系统时间
  2. 【Hibernate学习】 ——ORM(四)再次认识实体继承
  3. POJ 3233 Matrix Power Series 二分+矩阵乘法
  4. web端log4net输出错误日志到mysql
  5. Codeforces Round #332 (Div. 2)D. Spongebob and Squares 数学
  6. oc58--Category注意事项
  7. OST
  8. [NOIP 2014] 生活大爆炸版石头剪刀布
  9. 【POJ 1964】 City Game
  10. 杂项-Java:JNI