hdu 2510 符号三角形 回溯
来源:互联网 发布:linux crontab每月 编辑:程序博客网 时间:2024/04/28 23:47
2^n的回溯算法,n<=24,打表即可。
#include<iostream>#include<cstring>#include<cstdio>using namespace std;#define MAX 25//ashione 2012-4-19//打表,不打表会超时,因为回溯算法的时间复杂度是很高的。注释掉的代码是打表的。int q[MAX][MAX];int readc[MAX]={0,0,0,4,6,0,0,12,40,0,0,171,410,0,0,1896,5160,0,0,32757,59984,0,0,431095,822229};/*int sum,count;void make(int t,int n){ if(count>(n+1)*(n)/4 || (t-1)*t/2 - count>(n+1)*n/4) return ; if(t>n){ sum++;// cout<<"hello"<<endl; return ; } for(int i=0;i<2;i++){ q[1][t] = i; count+=i; for(int j=2;j<=t;j++){ q[j][t-j+1] = q[j-1][t-j+1]^q[j-1][t-j+2]; count+=q[j][t-j+1]; } make(t+1,n); for(int j=1;j<=t;j++) count-=q[j][t-j+1]; }}*/int main(){ int n;/* for(int i=1;i<=24;i++){ count = sum= 0; memset(q,0,sizeof(q)); if((i*(i+1)/2)%2 == 0) make(1,i); readc[i] =sum; cout<<readc[i]<<","; } cout<<endl;*/ while(cin>>n && n){ cout<<n<<" "<<readc[n]<<endl; } return 0;}
- hdu 2510 符号三角形 回溯
- HDU 2510 符号三角形 NYOJ491 幸运三角形 (回溯||打表) 代码带解释
- hdu 2510 符号三角形
- hdu-2510-符号三角形
- HDU 2510 符号三角形
- hdu 2510 符号三角形
- hdu 2510 符号三角形
- 回溯法-符号三角形
- 符号三角形 回溯法
- HDU 2510 符号三角形 NYOJ491 幸运三角形
- HDU 2510 符号三角形 【DFS】
- HDU 2510--符号三角形【DFS】
- HDU 2510 符号三角形 深搜打表
- 符号三角形问题 回溯法
- 回溯之符号三角形问题
- 符号三角形问题(回溯)
- 符号三角形问题(回溯)
- 符号三角形问题-回溯法
- Android Custom Dialog错误Unable to add window -- token null is not for an application
- Android开发:日期控件的使用(一)
- iphone软件点击评价按钮进入评论页面方法
- hdu 1171 Big Event in HDU(完全背包)
- 程序员的十层楼
- hdu 2510 符号三角形 回溯
- zju搜索题目、图论题目
- php实现加密和解密的简单代码
- WinCE 下最简单的字节对齐问题
- 第九周任务三之流运算符的重载
- 基数排序
- MFC 静态文本框修改内容
- 微处理器和微控制器的区别
- mini210的uboot编译使用