• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
tmeteorj
Nothing is so big that it is impossible to get over, and hurt only serves to make us stronger. 没有什么事是大到无法战胜的,痛苦也只会让我们变得更加坚强。
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理
上一页 1 ··· 16 17 18 19 20 21 下一页

2012年9月2日

POJ 3498
摘要: 拆点+最大流,对与拆开的点建立容量为最多跳几次的边,在建立源点到每个点的边,容量为那有多少只企鹅,最后让互相能到的点建立边。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int N=800,M=100000; 6 const int inff=1<<29; 7 const double eps=1e-8; 8 int head[N],nc; 9 struct edge 10 { 11 int 阅读全文
posted @ 2012-09-02 10:46 tmeteorj 阅读(147) 评论(0) 推荐(0)
 
POJ 2570
摘要: 可以看成floyd,用bool变量标记公司View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<set> 4 using namespace std; 5 bool ss[300][300][30]; 6 void floyd(int n) 7 { 8 for(int k=1;k<=n;k++) 9 {10 for(int i=1;i<=n;i++)11 {12 if(ss[i][k][26])13 {14 ... 阅读全文
posted @ 2012-09-02 09:33 tmeteorj 阅读(178) 评论(0) 推荐(0)
 
 

2012年9月1日

POJ 3432
摘要: 给一些点找正方形,其实就是枚举每两个点所形成的线段看它是否能和其它点组成正方形,将所有的点存在hash表里,然后枚举两个点,算出它能生成的正方形的另外两点的坐标,如果都在hash表里,则说明这两点连线能够生成一个正方形。另外,在考察每一个正方形,共有四条边,也就是说它在运算过程中被算了四次,最后ans再除以4便是答案。View Code 1 import java.util.*; 2 import java.math.*; 3 class Main 4 { 5 static int x[]=new int[2500]; 6 static int y[]=new int[250... 阅读全文
posted @ 2012-09-01 11:00 tmeteorj 阅读(274) 评论(0) 推荐(0)
 
POJ 2976
摘要: 算是一道裸的0-1分数规划,0-1规划正确性的证明请参考OI论文《最小割模型在信息学竞赛中的应用》,里面非常详细。总之,就是枚举比例,求a-bx的最大值,由于最多可以删去k个物品,实际就是保留n-k个,然后就在n个物品中选出最大的n-k个物品,然后再看剩下的物品里面权值为正就加进来,最后,看ans是否等于0View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 double a[1005],b[1005]; 6 const 阅读全文
posted @ 2012-09-01 09:45 tmeteorj 阅读(285) 评论(0) 推荐(0)
 
POJ 1248
摘要: 有很多这样的题,给一个这样的集合,让你去找几个数使他们加起来满足什么条件,一般要找4~6个数什么的,直接做就会超时,可以折半找2~3个数并将它们结果存起来,再另找2~3个数去验证。这样讲n^4~n^6就变成了n^2~n^3(用hash的话)View Code 1 import java.util.*; 2 import java.math.*; 3 class Main 4 { 5 static int pow(int a,int n) 6 { 7 int ans=1; 8 while(n>0) 9 {10 ... 阅读全文
posted @ 2012-09-01 08:51 tmeteorj 阅读(242) 评论(0) 推荐(0)
 
 

2012年8月30日

POJ 2042
摘要: 打表解之View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<cmath> 5 using namespace std; 6 const int N=(1<<15)+1; 7 int po[200],ans[N+2]; 8 int main() 9 {10 for(int i=1;i<200;po[i]=i*i,i++);11 memset(ans,0,sizeof(ans));12 for(int i1=1,tp1;p 阅读全文
posted @ 2012-08-30 18:54 tmeteorj 阅读(166) 评论(0) 推荐(0)
 
POJ 2738
摘要: 没什么好想的,就是一个记忆化搜索。我第一次居然想爆搜~~~View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int a[1005]; 6 int dp[1005][1005]; 7 int dfs(int left,int right) 8 { 9 if(dp[left][right]!=-1)10 return dp[left][right];11 else if(left==right-1)12 {13 ... 阅读全文
posted @ 2012-08-30 17:37 tmeteorj 阅读(408) 评论(0) 推荐(0)
 
POJ 3310
摘要: 题目给出的判断条件有三:无环,连通,存在一条链囊括所有的的结点或者邻接所有顶点。前两条件就不说了,第三个其实就是看一个结点它的儿子子树之中是否有大于2棵结点数超过1,另外,如果恰有2棵,还需看父亲祖辈是否有超过一个的结点。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int N=105,M=305; 6 int head[N],nc; 7 struct edge 8 { 9 int to,next;10 阅读全文
posted @ 2012-08-30 16:42 tmeteorj 阅读(276) 评论(0) 推荐(0)
 
POJ 3189
摘要: 被这题坑了多次,就一 二分+二分图多重匹配。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int N=1500,M=50000; 6 int head[N],nc; 7 struct edge 8 { 9 int x,y,next; 10 } edge[M]; 11 void add(int x,int y) 12 { 13 edge[nc].x=x; 14 edge[nc].y=y; 15 ... 阅读全文
posted @ 2012-08-30 16:09 tmeteorj 阅读(263) 评论(0) 推荐(0)
 
POJ 3411
摘要: 用mark[i][st]记录到达i点时到所有点情况为st时的最小花费,向下一步走的时候可以查看要到的点需要经过的中间点是否在st中,然后用优先队列+最短路便可以解决了。#include<cstdio>#include<cstring>#include<queue>using namespace std;const int N=12;int head[N],nc;struct edge{ int to,by,c1,c2,nxt;}edge[N*3];void add(int a,int b,int c,int c1,int c2){ edge[nc].to=b 阅读全文
posted @ 2012-08-30 14:17 tmeteorj 阅读(246) 评论(0) 推荐(0)
 
 
上一页 1 ··· 16 17 18 19 20 21 下一页

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3