hdu4403- A very hard Aoshu problem(搜索)
枚举等号的位置,然后暴力搜索一波 这个题本身不难,但它是我第一次使用对拍程序来查找错误,值得纪念。
#include<cstdio>
#include<string.h>
#include<map>
#include<algorithm>
#define inf 0x3f3f3f3f
const int maxn=;
using namespace std;
typedef pair<int,int> P;
int len,d,b,c,ans;
char a[maxn+];
map<P,int> m1,m2;
int cal(int l,int r){
if(l>r) return ;
int res=;
for(int i=l;i<=r;i++){
res=res*+a[i]-'';
}
return res;
}
void dfs(int l,int r,int sum,int f,int eq){
if(!f){
if(l>r){
m1[P(sum,eq)]++;
return ;
}
for(int i=l;i<=r;i++){
dfs(i+,r,sum+cal(l,i),,eq);
}
} else {
if(l>r){
m2[P(sum,eq)]++;
return ;
}
for(int i=l;i<=r;i++){
dfs(i+,r,sum+cal(l,i),,eq);
}
}
}
int main()
{
// freopen("e://duipai//data.txt","r",stdin);
// freopen("e://duipai//out1.txt","w",stdout);
while(scanf("%s",a)!=EOF){
if(a[]=='E')
break;
len=strlen(a);
ans=;
for(int i=;i<len;i++){
m1.clear();
dfs(,i-,,,i);
m2.clear();
dfs(i,len-,,,i);
map<P,int>::iterator it=m1.begin();
for(;it!=m1.end();++it){
int a=m1[P((*it).first.first,(*it).first.second)];
int b=m2[P((*it).first.first,(*it).first.second)];
if(a&&b) {
ans+=(a*b);
}
}
}
printf("%d\n",ans);
}
return ;
}
hdu4403- A very hard Aoshu problem(搜索)的更多相关文章
- HDU4403 A very hard Aoshu problem DFS
A very hard Aoshu problem Time Limit: 2000/1000 MS (Java/Others) Memory ...
- HDU 4403 A very hard Aoshu problem(DFS)
A very hard Aoshu problem Problem Description Aoshu is very popular among primary school students. I ...
- A very hard Aoshu problem(dfs或者数位)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4403 A very hard Aoshu problem Time Limit: 2000/1000 ...
- hdu 3699 10 福州 现场 J - A hard Aoshu Problem 暴力 难度:0
Description Math Olympiad is called “Aoshu” in China. Aoshu is very popular in elementary schools. N ...
- HDU 3699 A hard Aoshu Problem(暴力枚举)(2010 Asia Fuzhou Regional Contest)
Description Math Olympiad is called “Aoshu” in China. Aoshu is very popular in elementary schools. N ...
- HDU 3699 A hard Aoshu Problem (暴力搜索)
题意:题意:给你3个字符串s1,s2,s3;要求对三个字符串中的字符赋值(同样的字符串进行同样的数字替换), 替换后的三个数进行四则运算要满足左边等于右边.求有几种解法. Sample Input 2 ...
- A very hard Aoshu problem
A very hard Aoshu proble Problem Description Aoshu is very popular among primary school students. It ...
- Codeforces C. NP-Hard Problem 搜索
C. NP-Hard Problem time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- UVALive - 5107 - A hard Aoshu Problem
题目链接:https://vjudge.net/problem/UVALive-5107 题目大意:用ABCDE代表不同的数字,给出形如ABBDE___ABCCC = BDBDE的东西: 空格里面可以 ...
随机推荐
- BZOJ 1660 [Usaco2006 Nov]Bad Hair Day 乱发节:单调栈
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1660 题意: 有n头牛,身高分别为h[i]. 它们排成一排,面向右边.第i头牛可以看见在它 ...
- POJ 3071 Football:概率dp
题目链接:http://poj.org/problem?id=3071 题意: 给定n,有2^n支队伍参加足球赛. 给你所有的p[i][j],表示队伍i打败队伍j的概率. 淘汰赛制.第一轮(1,2)两 ...
- 安装.NET Core 3.0预览版后VS项目目标框架中不显示的解决方法
下载了微软在GitHub上的cSharpSamples项目后发现其中一些项目使用框架为.NET Core3.0,就下载了.NET Core3.0,但发现项目依然不可用,编译时提示如下 当前 .net ...
- spring属性注入DI
spring setter方式注入: 注入对象属性: 前提: 在bean对应实体中有对应的setter方法. 基础代码: 在bean中有另一个bean属性的setter方法. package cn.i ...
- (转)linux 打开文件数 too many open files 解决方法
too many open files 出现这句提示的原因是程序打开的文件/socket连接数量超过系统设定值. 查看每个用户最大允许打开文件数量 ulimit -a fdipzone@ubuntu: ...
- java中相对路径加载xml
一.xml文件一般的存放位置有三个: 1.放在WEB-INF下: 2.xml文件放在/WEB-INF/classes目录下或classpath的jar包中: 3.放在与解析它的java类同一个包中,不 ...
- 1066 Bash 游戏
传送门 1066 Bash游戏 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 有一堆石子共有N个.A B两个人轮流拿,A先拿.每次最少拿1颗,最多拿K颗,拿到最后1 ...
- OGG 11g Checkpoint 详解
OGG Checkpoint 详解 定位中断的位置,下次启动从中断的位置开始恢复. 1.target 端配置: 2.一条记录对应一个replicat 一. Extract Check ...
- vijos:P1155集合位置(次短路)
描述 每次有大的活动,大家都要在一起“聚一聚”,不管是去好乐迪,还是避风塘,或者汤姆熊,大家都要玩的痛快.还记得心语和花儿在跳舞机上的激情与释放,还记得草草的投篮技艺是如此的高超,还记得狗狗的枪法永远 ...
- POJ1986(LCA应用:求两结点之间距离)
Distance Queries Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 11304 Accepted: 3985 ...