HDU 2266 How Many Equations Can You Find(模拟,深搜)
2024-09-07 19:30:43
这是传说中的深搜吗。。。。不确定,,,,貌似更加像是模拟,,,,
//我要做深搜题目拉
//实际上还是模拟 #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 ;
}
最新文章
- node-sass报错解决方法
- 配置L2TP IPsec VPN (CentOS 6.5)
- phpstrom正则替换
- CSDN数据库被爆 统计CSDN用户都喜欢哪些密码
- 开发完整的Web项目必备
- [SDOI2015]权值
- ural 1207 Median on the Plane
- phpmyadmin自增字段
- MSSQLServer的备份与还原
- akoj-1055-矩阵乘法
- shapefile添加字段 设置文件名为字段内容
- 002_关于six版本过低报cannot import name urllib_parse的问题
- @PathVariable与@RequestBody的区别,及前段请求接口的写法。
- github 多人协作
- C# 中的浅表副本与深表副本
- 简述项目中优化sql语句执行效率的方法,从哪些方面,sql语句性能如何分析?
- R语言外部数据读取
- Struts 2 Tutorial
- Kotlin in Action 笔记
- 20155234 2016-2017-2 《Java程序设计》第8周学习总结