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

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)
 
POJ 2508
摘要: 直接将圆锥展开变成扇形,用比例算出夹角,再用余弦定理算出答案即可。#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;const double eps=1e-8,PI=acos(-1.0);int main(){ double r,h,l,p1,p2,th1,th2,dt; while(scanf("%lf%lf%lf%lf%lf%lf",&r,&h,&p1,&th1,&am 阅读全文
posted @ 2012-08-30 13:20 tmeteorj 阅读(199) 评论(0) 推荐(0)
 
POJ 2431
摘要: d,p记录当前距离与总油量,初始化就是题目给的值,然后每次从能到达的点中选择一个油量最多的点与p相加,即现在p代表去该点加油后又乘时光机回到原来位置的总油量~结束条件为:1、没有可以到达加油站了。2、d<=p,即能到终点了。#include<cstdio>#include<cstring>#include<algorithm>#include<queue>using namespace std;struct data{ int dis,val; bool operator<(const data &next)const { r 阅读全文
posted @ 2012-08-30 12:52 tmeteorj 阅读(656) 评论(0) 推荐(0)
 
POJ 1985
摘要: 最长链,两遍heap+dijiska#include<cstdio>#include<cstring>#include<algorithm>#include<queue>using namespace std;const int N=40005;int head[N],nc;struct edge{ int to,cost,next;}edge[N*3];void add(int a,int b,int c){ edge[nc].to=b;edge[nc].next=head[a];edge[nc].cost=c;head[a]=nc++; ed 阅读全文
posted @ 2012-08-30 11:17 tmeteorj 阅读(304) 评论(0) 推荐(0)
 
 

公告


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