HDU 4502 吉哥系列故事——临时工计划
摘要:简单的动态规划题目#include using namespace std;struct node { int s,e,v;};int dp[105];int main(){ node job[1005]; int n,m,t; int i,j; cin>>t; while(t--) { cin>>m>>n; for(i=0;i>job[i].s>>job[i].e>>job[i].v; for(i=0;i<=m;i++) dp[i]=0; for(i=1;i<=m;i++) { for(j=0;j<n;j++
阅读全文
posted @
2013-06-25 17:11
努力ing
阅读(164)
推荐(0)
HDU 1856
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1856并查集的题目find()函数用到路径压缩,init()利用的是kruskal的思想#include<iostream>using namespace std;#define MAX 10000010struct node { int p; int r;};node f[MAX];int n,sum;void init(){ int i; for(i=0;i<MAX;i++) { f[i].p=i; f[i].r=1; }}int find(int x){ int t=f[x].p; i
阅读全文
posted @
2013-05-29 21:24
努力ing
阅读(147)
推荐(0)
HDU 1506
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1506第一种方法:#include<stdio.h>int a[100005];int right[100005];int left[100005];int main(){ int n; int i; __int64 max; while(scanf("%d",&n)!=EOF&&n) { for(i=0;i<n;i++){ scanf("%d",&a[i]); left[i]=right[i]=i; } for(i=0
阅读全文
posted @
2013-05-26 10:13
努力ing
阅读(122)
推荐(0)
HDU 1864
摘要:简单dphttp://acm.hdu.edu.cn/showproblem.php?pid=1864#include<iostream>#include<string>using namespace std;double dp[50];double max(double a,double b){ return a>b?a:b;}int main(){ int m,n,j,i; double val,A,B,C; char c; double v; double sum[30]; int flag; while(cin>>val>>n&
阅读全文
posted @
2013-05-25 14:29
努力ing
阅读(128)
推荐(0)
hdu 1978
摘要:记忆搜索http://acm.hdu.edu.cn/showproblem.php?pid=1978题目简述:机器人从第一个点出发到达最后一点,有多少种方法,结果%10000;Input166456643223172114627584395766215311372Output3948第一种方法:#include<iostream>using namespace std;int n,m;int map[205][205];int dp[205][205];int min(int a,int b){ return a<b?a:b;}int bfs(int x,int y,int
阅读全文
posted @
2013-05-23 15:46
努力ing
阅读(161)
推荐(0)
hdu 1081
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1081矩阵压缩的题目#include<iostream>using namespace std;int find(int a[],int n) //找最大子序列{ int max=-10004; int i,sum=0; for(i=0;i<n;i++) { sum+=a[i]; if(sum>max) max=sum; if(sum<0) sum=0; } return max;}int main(){ int i,j,k,n; int a[150][150]; while(c
阅读全文
posted @
2013-05-19 21:58
努力ing
阅读(126)
推荐(0)
HDU1574 RP问题
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1574题目大意:如果a>0并且当前rp值大于或等于b时,才有可能发生如果a<0并且当前rp值小于或等于b是,才有可能发生事件有可能不发生,有可能发生分析:以第三组数据为例:3-50410-5-5-5510初始化:rp数组INFINF…………INF0INF…………INF01l=r=10000;20005第一事件发生:因为a<0;所以b+10000到r之间都有可能发生,用for循环2rp数组INFINF……4……0INFINF……INF01l=l+a=9995;r=10000;第二事件发生:因为
阅读全文
posted @
2013-05-19 16:50
努力ing
阅读(213)
推荐(1)