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

2012年10月19日

POJ 3347
摘要: 题意:变长不同的n个正方形,斜45度按顺序平放在坐标轴上,尽量靠左但不能跃出x=0,问从上往下看,哪些正方形是可见的。题解:1、假如前i-1个正方形位置都确定了,那么可以让第i个正方形与前i-1个正方形每个都计算一次它如果和它相依靠的话左边坐标的值,然后取一个最大的便是这个正方形的左端点位置。 2、对于j<i的正方形,如果i的边长大于j那么j的最右能看到的部分就不会比i的最左端点大,反之,i的最左能看到的部分就不会比j最右端点小。 3、通过第2步筛选,将那些最左能看到的端点比最右能看到端点大或等于的去掉,剩下的就是所要求的。View Code 1 #include<cstdio&g 阅读全文
posted @ 2012-10-19 14:42 tmeteorj 阅读(662) 评论(1) 推荐(2)
 
POJ 3486
摘要: 题意:需要n年都有电脑用,有两种方法,一种是修理电脑,一种是换新电脑。一台新电脑价值为c,第i台电脑在第i年发行,将它维修至第j年的费用会告诉你,求最低消费。题解:dp[i]为前i年都有电脑用的最小花费,那么dp[i]=min(dp[j-1]+c+a[j][i]),即前j-1年有电脑用的最小花费加上买第j年电脑一直用到第i年的花费中取一个最小值。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int N= 阅读全文
posted @ 2012-10-19 13:33 tmeteorj 阅读(277) 评论(0) 推荐(0)
 
POJ 2662
摘要: 题意:求无向图中从1走到2的满足条件的路径条数,条件:从A能到B,当且仅当B到终点的最短路径小于A到终点的最短路径。题解:spfa预处理所有点到终点的距离,记忆化搜索统计个数。View Code 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 const int N=1005,M=4000000; 6 int dist[N],head[N],list[N],dp[N],r,f,nc; 7 bool vis[N]; 8 struct Ed 阅读全文
posted @ 2012-10-19 12:57 tmeteorj 阅读(206) 评论(0) 推荐(0)
 
POJ 1105
摘要: 题意:给出一个深度为n的满二叉树(根节点为0层),每层都有一个变量xi,然后2^n叶子结点被赋值为0,1。然后给出m个给xi赋值的情况,遇到0就朝左孩子走,反之就右孩子,将遍历到的m个叶子结点输出来。题解:弄清满二叉树中左孩子就是now*2,右孩子为now*2+1,其他就是模拟了。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int main() 6 { 7 int n,ca=0; 8 while(scanf(&q 阅读全文
posted @ 2012-10-19 12:24 tmeteorj 阅读(299) 评论(0) 推荐(0)
 
POJ 1788
摘要: 题意:给一个什么东西修围墙,只能修水平或者竖直的那种,然后每个拐点都会告诉你坐标,求最后围墙长度。题解:由于围墙只有横竖,可以分两次每次统计横的或者竖的的总长度,统计方法就是按照如x坐标排序,求相邻x坐标相等的两个点间的y的差值。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 struct data 6 { 7 int x,y; 8 }po[101000]; 9 bool compx(data a,data b)10 阅读全文
posted @ 2012-10-19 11:38 tmeteorj 阅读(249) 评论(0) 推荐(1)
 
 

2012年10月18日

POJ 2441
摘要: 题意:n头牛,m个牧场,每头牛都有自己喜欢的牧场,然后问一牛一牧场的分配方案总数。题解:状态压缩dp,dp[i][state]为前i头牛,用了state的牧场时的总数。但是直接开n*2^m会爆空间,但是每头牛都只与前面一头牛相关,所以可以辗转一下,只记录两维即可。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int dp[2][(1<<20)+2]; 6 int main() 7 { 8 int n,m 阅读全文
posted @ 2012-10-18 21:50 tmeteorj 阅读(310) 评论(0) 推荐(0)
 
POJ 2424
摘要: 题意:给出饭店来人的顺序与人数,按照三种类型去坐,如果等待时间超过半个小时,客人就会走,问最后能接待多少客人。题解:大模拟!View Code 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #include<queue> 5 using namespace std; 6 struct data 7 { 8 int t; 9 bool operator<(const data &ne)const 10 { 11 return t>ne.t; 12 } 阅读全文
posted @ 2012-10-18 21:24 tmeteorj 阅读(299) 评论(0) 推荐(0)
 
POJ 3497
摘要: 题意:给出预算b以及电脑零件n,每种类型均要买一个,求在预算范围内,所有零件配置最低的最大值。题解:二分答案View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<map> 5 #include<string> 6 #include<vector> 7 using namespace std; 8 map<string,int> MP; 9 const int inf=0x3f3f3f3f;10 stru 阅读全文
posted @ 2012-10-18 17:26 tmeteorj 阅读(356) 评论(0) 推荐(0)
 
POJ 1589
摘要: 题意:给出n个字符串,排成阵列,要求每行长度不超过60,且每列宽度为n个字符串中最长的那个的长度加2,最后一列就是最长的长度,要使行数尽可能少。题解:直接推导出最后需要多少行多少列,细心一点就没问题了。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 char file[102][102][65]; 6 struct data 7 { 8 char s[70]; 9 bool operator<(const da 阅读全文
posted @ 2012-10-18 13:46 tmeteorj 阅读(189) 评论(0) 推荐(0)
 
POJ 2261
摘要: 题意:16个国家的竞赛图,给出每个国家打败其他国家的概率,求每个国家最后夺冠的概率。题解:dp[i][k]代表第i个国家成功进入第k轮的概率,那么dp[i][k]=sum(dp[i][k-1]*dp[j][k-1]*vs[i][j]),其中,j为这一轮i可能面对的国家。PS:国家名字占10个字符,还需要空一格再输出概率~View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 char name[20][50]; 6 doub 阅读全文
posted @ 2012-10-18 13:24 tmeteorj 阅读(290) 评论(0) 推荐(0)
 
 
上一页 1 2 3 4 5 6 7 ··· 21 下一页

公告


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