hdu 4403
水水的dfs
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm> using namespace std;
char b[20];
int a[20], ans;
void dfs(int cur, int len)
{
if(cur == len - 1)
{
a[cur] = 1;
int d[2] = {}, k = 0;
int e = 0,flag = 1;
for(int i = 0; i < len; i++)
{
if(a[i] == 0)
e = e * 10 + b[i] - '0';
else if(a[i] == 1)
{
d[k] += e * 10 + b[i] - '0';
e = 0;
}
else if(a[i] == 2)
{
d[k] += e * 10 + b[i] - '0';
e = 0;
k++;
}
if(k >= 2)
{
flag = 0;
break;
}
}
if(flag && d[0] == d[1])
ans++;
}
else
{
for(int i = 0; i < 3; i++)
{
a[cur++] = i;
dfs(cur, len);
cur--;
}
}
}
int main()
{
while(scanf("%s",b) == 1 && strcmp(b, "END"))
{
ans = 0;
int len = strlen(b);
int cur = 0;
for(int i = 0; i < 3; i++)
{
a[cur++] = i;
dfs(cur ,len);
cur--;
}
printf("%d\n",ans);
}
return 0;
}
hdu 4403的更多相关文章
- HDU 4403 A very hard Aoshu problem(dfs爆搜)
http://acm.hdu.edu.cn/showproblem.php?pid=4403 题意: 给出一串数字,在里面添加一个等号和多个+号,使得等式成立,问有多少种不同的式子. 思路: 数据量比 ...
- hdu 4403 dfs
巨麻烦的模拟题orz.... 先确定等号的位置,然后两层dfs,分别算等号前面的和后面的,再比较 话说这题竟然不开long long都能水过 #include <iostream> #in ...
- hdu 4403 简单搜索
思路:分等号左边和右边进行搜索 #include<iostream> #include<cstdio> #include<cstring> #include< ...
- hdu 4403 枚举
#include<cstdio> #include<cstring> #include<iostream> #include<cmath> #inclu ...
- HDU 4403 A very hard Aoshu problem(DFS)
A very hard Aoshu problem Problem Description Aoshu is very popular among primary school students. I ...
- HDU 4403 A very hard Aoshu problem
暴力$dfs$. 先看数据范围,字符串最长只有$15$,也就是说枚举每个字符后面是否放置“$+$”号的复杂度为${2^{15}}$. 每次枚举到一种情况,看哪些位置能放“$=$”号,每个位置都试一下, ...
- hdu 4403 爆搜
题意:给一串数字,在其间加入若干加号和一个等号,问使等式成立的方案总数 if the digits serial is "1212", you can get 2 equation ...
- HDU 4403 A very hard Aoshu problem (DFS暴力)
题意:给你一个数字字符串.问在字符串中间加'='.'+'使得'='左右两边相等. 1212 : 1+2=1+2, 12=12. 12345666 : 12+3+45+6=66. 1+2+3+4 ...
- [GodLove]Wine93 Tarining Round #6
比赛链接: http://vjudge.net/contest/view.action?cid=47642#overview 题目来源: 2012 ACM/ICPC Asia Regional Jin ...
随机推荐
- Unity3D除了在编辑器里,怎么用代码给一个Texture类型的变量赋值
resource.load上来一张贴图就行. using UnityEngine; using System.Collections; public class example : MonoBehav ...
- DOS批处理命令-goto命令
goto是一个流程控制语句 rem goto语句是一个大家都不怎么喜欢的语句,因为他的随意性太强,导致可维护性大大的降低. 语法: goto [lable] [lable]是bat程序中任意定义的 ...
- windows编程socket问题
今天调试了个MFC网络程序,被bug困扰了一天,终于在收工前解决了. 大致是这样的,我们需要用上位机远程控制机器车前行.上位机上的MFC app的键盘按键响应如下:当按键按下时,系统会发送一个消息给a ...
- C# 线程--第三线程池
概述 线程池有那些优点: 1.在多线程中线程池可以减少我们创建线程,并合理的复用线程池中的线程.因为在线程池中有线程的线程处于等待分配任务状态. 2.不必管理和维护生存周期短暂的线程,不用在创建时为其 ...
- System.Windows.Forms.Timer
一.主要属性.方法和事件 Windows 窗体 Timer 是定期引发事件的组件.该组件是为 Windows 窗体环境设计的. 时间间隔的长度由 Interval 属性定义,其值以毫秒为单位.若启用了 ...
- ASP.NET Cache的一些总结分享
最近我们的系统面临着严峻性能瓶颈问题,这是由于访问量增加,客户端在同一时间请求增加,这迫使我们要从两个方面解决这一问题,增加硬件和提高系统的性能. 1.1.1 摘要 最近我们的系统面临着严峻性能瓶颈问 ...
- jqGrid API 相关
取消所有选中的行: $("jqgridtableid").trigger("reloadGrid"): 设定选中行,可设定多行选中: $("jqgri ...
- IPoint从自定义的投影坐标系转换到自定义的地理坐标系
IPoint pointStart = new PointClass(); pointStart = xyPolyline.FromPoint; ISpatialReferenceFactory pS ...
- Linux multiple open a device
Linux multiple open a device a device = /dev/wiegand Linux在多次打开同一个设备(/dev/wiegand)的时候,打开结果都是成功,但是在用w ...
- Linux C 程序 文件操作(Linux系统编程)(14)
文件操作(Linux系统编程) 创建一个目录时,系统会自动创建两个目录.和.. C语言实现权限控制函数 #include<stdio.h> #include<stdlib.h> ...