符号三角形(hdu 2510 搜索+打表)
符号三角形
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1246    Accepted Submission(s):
664
号下面是”-“ 。计算有多少个不同的符号三角形,使其所含”+“ 和”-“ 的个数相同 。 n=7时的1个符号三角形如下:
+ + - + - + +
+ - - - - +
- + + + -
- + + -
- + -
- -
+
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int a[];
char res[][];
int sum;
bool count(int n)
{
int p1=,p2=;
int i,j;
for(i=;i<=n;i++)
{
if(res[][i]=='+') p1++;
else p2++;
}
for(int i=;i<n;i++)
for(j=;j<=n-i;j++)
{
res[i][j]=(res[i-][j]==res[i-][j+]?'+':'-');
if(res[i][j]=='+') p1++;
else p2++;
}
if(p1==p2)
return ;
return ;
}
void dfs(int n,int s)
{
int i,j;
if(s>n)
{
if(count(n))
sum++;
return;
}
res[][s]='+';
dfs(n,s+);
res[][s]='-';
dfs(n,s+);
return;
}
int main()
{
int n;
int i,j;
a[]=a[]=;
for(i=;i<=;i++)
{
sum=;
dfs(i,);
a[i]=sum;
cout<<a[i]<<endl;
}
}
符号三角形(hdu 2510 搜索+打表)的更多相关文章
- hdu 2510 符号三角形 (DFS+打表)
		
符号三角形 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
 - 符号三角形_hdu_2510(深搜).java
		
http://acm.hdu.edu.cn/showproblem.php?pid=2510 Time Limit: 2000/1000 MS (Java/Others) Memory Limi ...
 - 符号三角形——F
		
F. 符号三角形 Time Limit: 1000ms Memory Limit: 32768KB 64-bit integer IO format: Java class name: 符号 ...
 - code vs 3376 符号三角形
		
3376 符号三角形 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description 如下图是由14个“+”和14个“-”组 ...
 - OpenJudge 2990:符号三角形 解析报告
		
2990:符号三角形 总时间限制: 1000ms 内存限制: 65536kB 描述 符号三角形的第1行有n个由“+”和”-“组成的符号 ,以后每行符号比上行少1个,2个同号下面是”+“ ...
 - hdu 1496 Equations hash表
		
hdu 1496 Equations hash表 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 思路: hash表,将原来\(n^{4}\)降 ...
 - hdu 5887 搜索+剪枝
		
Herbs Gathering Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
 - hdu 5636 搜索 BestCoder Round #74 (div.2)
		
Shortest Path Accepts: 40 Submissions: 610 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: ...
 - 【a502】符号三角形问题
		
Time Limit: 1 second Memory Limit: 32 MB [问题描述] 在一般情况下,符号三角形的第一行有n个符号.按照2个同号的下面是"+"号,2个异号的 ...
 
随机推荐
- 异步编程设计模式Demo - PrimeNumberCalculator
			
using System; using System.Collections; using System.Collections.Specialized; using System.Component ...
 - Linux_Shell type
			
Recommendation is to use the bash shell, because he is strong enough, and absorbed the useful proper ...
 - C语言日期时间标准库
			
用思维导图整理: 代码: #include <stdio.h> #include <time.h> #include <string.h> int main() { ...
 - 动态修改ActionBar Menu的显示
			
应用场景: 在主Activity中,采用InstrumentedActivity侧边栏的方式,侧边栏的每一项对应一个Fragment,要实现不同的Fragment动态显示与隐藏ActionBar Me ...
 - ExpandableListView 保证只展开一组
			
expandableListView.setOnGroupExpandListener(new OnGroupExpandListener(){ @Override public void onGro ...
 - Android得到控件在屏幕中的坐标
			
getLocationOnScreen ,计算该视图在全局坐标系中的x,y值,(注意这个值是要从屏幕顶端算起,也就是索包括了通知栏的高度)//获取在当前屏幕内的绝对坐标 getLocationInWi ...
 - Android之SharedPreferences两个工具类
			
相信Android的这个最简单的存储方式大家都很熟悉了,但是有一个小小技巧,也许你没有用过,今天就跟大家分享一下,我们可以把SharedPreferences封装在一个工具类中,当我们需要写数据和读数 ...
 - 单线多拨,傻瓜式openwrt单线多拨叠加速率教程
			
http://bbs.pceva.com.cn/thread-98362-1-1.html
 - bzoj1755 [Usaco2005 qua]Bank Interest
			
Description Farmer John made a profit last year! He would like to invest it well but wonders how muc ...
 - 异步套接字基础:select函数以及FD_ZERO、FD_SET、FD_CLR、FD_ISSET
			
参考:[原创]技术系列之 网络模型(三)多路复用模型 select函数 select函数: 系统提供select函数来实现多路复用输入/输出模型.原型: #include <sys/time.h ...