BUAA_2012_Summer
文章平均质量分 72
Balloons2012
这个作者很懒,什么都没留下…
展开
-
三分法求极值
三分求解凹凸函数的极值问题。Party All the TimeTime Limit: 2000msMemory Limit: 32768KBIn the Dark forest, there is a Fairy kingdom where all the spirits will go together and Cel原创 2012-08-13 09:42:17 · 1268 阅读 · 0 评论 -
hdu 4274
其实这题挺水的,当时就老往并查集上想,搞得昏天暗地的。#include#include#include#define LL long long#define INF (1<<31-1)using namespace std;vector son[10010];int L[10010],R[10010]; int ans; int sum[10010];void initia原创 2012-09-15 11:10:44 · 742 阅读 · 0 评论 -
hdu 2844(背包)
#include#include#includeusing namespace std;int dp[100010],w[110],c[110];int main(){ int n,m,i,j,k,cnt; while( scanf("%d%d",&n,&m),n+m ) { cnt=0; memset(dp,0,sizeof(d原创 2012-10-06 19:31:06 · 877 阅读 · 0 评论 -
hdu4277 USACO ORZ
import java.util.HashSet;import java.util.Scanner;public class Triangle { int a,b,c; int arr[]=new int[1010],n,sum; long M=200010; HashSet mp=new HashSet(); void dfs(int d){ if(d>n){ if(a转载 2012-10-05 16:33:19 · 504 阅读 · 0 评论 -
扩展欧几里德
int extended_euclidean(int n, int m, int &x, int &y) { if (m == 0) { x = 1; y = 0; return n; } int g = extended_euclidean(m, n % m, x, y); int t = x - n / m * y; x = y; y = t; return转载 2012-10-05 18:18:02 · 443 阅读 · 0 评论 -
poj 1635( 树的最小表示法判断同构 )
#include#include#include#include#include#includeusing namespace std;string dfs(char* ss,int s,int t){ int i,j=s,h=0; int cnt=0; vector str; str.clear(); if( s>=t ) { s原创 2012-10-05 11:38:13 · 1659 阅读 · 0 评论 -
hdu 4267
按余数对数分组,tree[i][j]表示被i除余j的数的序列; 然后用10*10个树状数组就可以做了。是区间更新,单点求值。#include#define lowbit(x) ((x)&(-x))#includeint tree[11][11][50002];int a[50002]; int n;void update(int k,int i,int j,int c){原创 2012-09-11 16:56:43 · 561 阅读 · 0 评论 -
hdu 4268 贪心
STL是多么重要啊。#include#include#includeusing namespace std;typedef struct{ int h,w;}Node; Node Alice[100010],Bob[100010]; multiset s;int cmp(Node a,Node b){ if(a.w==b.w) return a.h<b.h;原创 2012-09-11 23:29:15 · 759 阅读 · 0 评论 -
LCA 与 RMQ
求LCA可以用tarjan算法(见代码); 这里不详细介绍了。用到的东西主要是dfs + 并查集。 详见最下面的代码。还有一种方法是利用 倍增的思想 求。具体就是: f[i][j] 表示i的第2^j次方个祖先是谁。 则f[i][j]= f[ f[i][j-1] ][j-1]; (j>0) f[i][j]=father[i];(j==0) 这样可以处理出每个节点的原创 2012-08-26 18:40:23 · 1916 阅读 · 1 评论 -
HDU 4340 树形DP
2012 Multi-University Training Contest 5Capturing a countryTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionAnt and Bob two army want to cap原创 2012-08-18 02:39:01 · 773 阅读 · 0 评论 -
hdu 4412 Sky Soldiers (dp)
具体思路的解释见 http://hi.baidu.com/renxl51/item/d7437a30bca43883f4e4ad0df[i][j] 表示用j个点覆盖前i个点。 f[i][j]=min{ f[k][j-1] + cost } ( j-1 #include#include#include#include#define INF ((1<<23)-1)u原创 2012-10-07 19:53:42 · 1070 阅读 · 0 评论