- 博客(16)
- 资源 (1)
- 收藏
- 关注
原创 poj 1050动态规划+最大子矩阵和+二维化为一维来求最大子串和值
/*二维化为一维来求最大子序列值*/#include#includeusing namespace std;int Arr[110][110] = { 0 },N=0,sum1=0,max1=0;void dp(int n){ int a = 0; sum1 += Arr[n][1]; for (a = 2; a <= N; a++) { if (sum1 < 0)
2014-08-30 00:14:06 301
原创 poj 1088+动态规划+记忆化搜索
/*不能找最高点进行搜索1 1 11 0 11 1 1*/#include#includeusing namespace std;int Arr[110][110] = { 0 }, R = 0, C = 0, dp[110][110] = { 0 };//dp存储长度,记忆化搜索int dfs(int row, int colum){ if (dp[row][colum]
2014-08-29 11:58:25 336
原创 poj2533 动态规划+最长上升子序列
#include#includeusing namespace std;int Arr[10000] = { 0 }, dp[10000] = { 0 };int main(){int N = 0, i = 0,j=0,maxlength=0;cin >> N; for (i = 0; i dp[i] = 1; for (i = 0; i ci
2014-08-28 19:24:28 339
原创 poj3126广搜、筛选法
#include#include#define N 10000using namespace std;int flag[N + 1] = { 0 }, prime[N + 1] = { 0 },pnum=0,a = 0, b = 0;struct number{int prime,step;}queue[20000];void searchprime(){
2014-08-28 11:22:46 340
原创 筛选法求素数
/*1. 每个合数必有一个最大因子(不包括它本身) ,用这个因子筛选合数 2.对于每一个数i,乘上 小于等于i的最小素因数 的素数,就得到以i为最大因数的合数。 3设有一个数t,只要将 所有以比t小的数为最大因数 的合数筛去,*/
2014-08-28 01:37:01 657
原创 poj1321变种8皇后
#include#includeusing namespace std;char Arr[8][8] = { '\0' };int num = 0, k = 0, n = 0, map[8] = { 0 };void dfs(int row, int p){ int a = 0,b=0;if (p == k) {num++;return;}if
2014-08-27 18:54:22 335
原创 八皇后问题
#include#include#includeusing namespace std;int Arr[8][8] = { 0 },num=0;int valid(int h, int v){int x = 0, y = 0;for (x = 0; x {for (y = 0; y {if (Arr[x][y]){if (x == h) re
2014-08-27 00:06:49 345
原创 poj1664+放苹果+递归和动态规划
#include#includeusing namespace std;int dp(int m, int n){if (m == 1 || n == 1||m==0||n==0) return 1;else if (m 0&&n>0) return dp(m, m);else if(m>=n&&m>0&&n>0) return dp(m, n - 1) + dp(
2014-08-26 18:55:05 362
原创 poj2299+归并排序+注意输出来的那个数据的类型。。。
#include#include#include#includeusing namespace std;int Arr[500005] = { 0 }, temp[500005] = { 0 }, N = 0;__int64 num;void merge(int low,int m, int high){int i = low, j = m + 1,n=0,le
2014-08-26 14:17:28 456
原创 poj2388快排
#include#includeusing namespace std;int Arr[10000] = { 0 };void qsort(int Left, int right){ int temp = 0; if (Left >= right) return; if (right - Left == 1){ if (Arr[Left] > Ar
2014-08-25 22:34:17 450
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人