摘要: 一开始想用多次求最长下降子序列方法做:有多少个最长下降子序列,就需要多少台系统。但是wa了然后就想到,保存每台系统能发射的最大高度h[i],如果某个导弹的高度H>所有h[i],则需要添加一台系统了;否则,h[i]=H(h要排序,贪心)View Code #include <stdio.h>#include <algorithm>using namespace std;int main(){ int n,m,i,j,min,h[10000],ar[10000]; while (scanf("%d",&n)!=EOF) { for (i=0 阅读全文
posted @ 2011-11-10 20:05 104_gogo 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 把花生数按从大到小排序,然后一个一个的去试,能摘就摘,不能摘就结束了.View Code #include<cstdio>#include<cmath>#include<algorithm>using namespace std;struct node{ float x,y; int num;}a[2505];float cmp(node x,node y){ return x.num>y.num;}int main(){ int i,j,k,n,r,c,num,ans,len,step,limit; scanf("%d",& 阅读全文
posted @ 2011-11-10 14:10 104_gogo 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 记忆化dfs当搜索到一个位置,如果这个位置的下面已经被搜索过了,则直接返回它的值View Code #include <stdio.h>#include <string.h>int n;__int64 vis[36][36];char board[36][36];__int64 dfs(int x,int y){ int i; if(x==n-1&&y==n-1)return 1; if(board[x][y]=='0')return 0; if(vis[x][y])return vis[x][y]; if(x+board[x][y]-& 阅读全文
posted @ 2011-11-10 11:56 104_gogo 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 0-1背包dp[i]=max(dp[i],1-(1-dp[i-a])*(1-b));dp[j]表示当选择一所学校,用 i 这么多钱的时候他可以收到至少一份offer的最大概率View Code #include <stdio.h>#include <string.h>float max(float a,float b){ return a>b?a:b;}int main(){ int n,m,i,j,a; float b,dp[10005]; while (scanf("%d%d",&n,&m)!=EOF) { if(n==0& 阅读全文
posted @ 2011-11-10 10:01 104_gogo 阅读(167) 评论(0) 推荐(0) 编辑