hdu 4403 枚举
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std; const int maxe = ;
const int maxn = ;
const int INF = 0x3f3f3f; vector<int> l[maxn];
vector<int> r[maxn]; char s[maxn]; inline int cal(int a,int b){
int ret = ;
for(int i=a;i<=b;i++)
ret = ret* + s[i] - '';
return ret;
}
int main()
{
//freopen("E:\\acm\\input.txt","r",stdin); while(scanf("%s",s+) && s[]!='E'){
int N = strlen(s+);
for(int i=;i<=N;i++) l[i].clear();
for(int i=;i<=N;i++) r[i].clear(); l[].push_back(s[]-'');
for(int i=;i<=N-;i++){ for(int j=;j<i;j++){
int num = cal(j+,i);
if(j == ){
l[i].push_back(num);
continue;
}
for(int k=;k<l[j].size();k++){
l[i].push_back(l[j][k] + num);
}
}
sort(l[i].begin(),l[i].end());
}
r[N].push_back(s[N]-'');
for(int i=N-;i>=;i--){
for(int j=N+;j>i;j--){
int num = cal(i,j-);
if(j == N+){
r[i].push_back(num);
continue;
}
for(int k=;k<r[j].size();k++){
r[i].push_back(r[j][k] + num);
}
}
sort(r[i].begin(),r[i].end());
} int ans = ;
for(int i=;i<=N-;i++){
for(int j=;j<l[i].size();j++){
for(int k=;k<r[i+].size();k++){
if(l[i][j] == r[i+][k]){
ans++;
}
}
}
}
printf("%d\n",ans);
}
}
hdu 4403 枚举的更多相关文章
- hdu 4770(枚举 + dfs爆搜)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4770 思路:由于最多只有15个".",可以直接枚举放置的位置,然后判断是否能够全部 ...
- hdu 3006 枚举集合能够产生的全部并集的集合
http://acm.hdu.edu.cn/showproblem.php? pid=3006 刚买的CHERRY键盘 手感真好 可惜不习惯 写代码老是打错.一个题写了一上午,都是各种按错键DEBUG ...
- HDU 4403 A very hard Aoshu problem(dfs爆搜)
http://acm.hdu.edu.cn/showproblem.php?pid=4403 题意: 给出一串数字,在里面添加一个等号和多个+号,使得等式成立,问有多少种不同的式子. 思路: 数据量比 ...
- hdu 5129 (枚举) The E-pang Palace
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5128. 给你n个点,问能否组成两个不相交的与坐标轴平行的矩形,能就输出两矩形的面积和,不能就输出一个字符串 ...
- hdu 4282 枚举,非二分
http://acm.hdu.edu.cn/showproblem.php?pid=4282 对于方程X^Z + Y^Z + XYZ = K,已知K求此方程解的个数,其中要求X<Y,Z>1 ...
- HDU 5225 枚举
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5225 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- hdu 4681(枚举+dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4681 思路:首先预处理出串C在A,B中的所有的位置,然后从前向后求一次最长公共子序列,从后向前求一次最 ...
- hdu 4421(枚举+2-sat)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4421 思路:枚举32位bit,然后2-sat判断可行性,这里给出2-sat矛盾关系构图: 1.a&am ...
- HDU 5965 枚举模拟 + dp(?)
ccpc合肥站的重现...一看就觉得是dp 然后强行搞出来一个转移方程 即 根据第i-1列的需求和i-1 i-2列的枚举摆放 可以得出i列摆放的种类..加了n多if语句...最后感觉怎么都能过了..然 ...
随机推荐
- asp.net命名规范
以下命名规范是在编程中,可以辅助快速编程的良好方式之一,我一点点的整理出来,以便形成自己的编程规范.还有待完善... 0.产品命名规范: 结构 层次 产品 模块 功能 命名规则 UI(界面层) Web ...
- C++专题 - WPS是什么
WPS,1988年诞生自一个叫求伯君的24岁年轻人之手,市场占有率一度超过90%,这个产品也成就了这个年轻人.在中国大陆,金山软件公司在政府采购中多次击败微软公司,中国大陆很多政府机关部门.企业都装有 ...
- DFS的基础训练清单
HDU 1010 (AC) HDU 1015 (AC) HDU 1016 (AC) HDU 1172 (AC) HDU 1312 (AC) POJ 2362 (AC,1011 ...
- 8种CSS清除浮动的方法优缺点分析
为什么清除CSS浮动这么难? 因为浮动会使当前标签产生向上浮的效果,同时会影响到前后标签.父级标签的位置及 width height 属性.而且同样的代码,在各种浏览器中显示效果也有可能不相同,这样让 ...
- 【转】Eclipse工具使用技巧总结
作者:Work Hard Work Smart 出处:http://www.cnblogs.com/linlf03/ 可参考http://www.codeceo.com/article/eclipse ...
- php读取excel,以及php打包文件夹为zip文件
1.把文件下载到本地,放在在Apache环境下2.d.xlsx是某游戏的服务器名和玩家列表,本程序只适合此种xlsx文件结构,其他结构请修改index.php源码3.访问zip.php的功能是把生成的 ...
- php开源项目学习二次开发的计划
开源项目: cms 国内 dedecms cmstop 国外 joomla, drupal 电商 国内 ecshop 国外 Magento 论坛 discuz 博客 wordpress 学习时 ...
- Uninstall office15 click-to-run extensibility Component
Summary : Uninstall office15 click-to-run extensibility Component,How to resolve Uninstall office15 ...
- JS贪吃蛇游戏
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- BCB 语言类
整理日: 2015年2月16日 EcLanguage.h /*--------------------------------------------------------------------- ...