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

2012年10月4日

POJ 1732
摘要: 题意:每个小写字母对应一个数字,然后给你一串数字和一些单词,找出一些单词对应这些数字,并且使得用的单词数最少。题解:dp[i]代表覆盖住前i个数字的最小花费,如果s能覆该[i,j]则dp[j]=min(dp[j],dp[i-1]+1),判断能否覆盖方法就多了KMP/HASH/AC自动机都行,map也可以水过。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<map> 4 #include<string> 5 using namespace std; 6 const int in 阅读全文
posted @ 2012-10-04 20:01 tmeteorj 阅读(385) 评论(0) 推荐(0)
 
POJ 1972
摘要: 题意:n个骰子按顺序立成一个栈,求正面向你的那一面的和的最大值。题解:由于规定了顺序,这题也就毫无技术可言了,直接6的枚举第一个骰子的top面其余就确定了。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int getmax(int a,int b) 6 { 7 for(int i=6;i>=4;i--) 8 if(i!=a&&i!=b) 9 return i;10 }11 int po[100 阅读全文
posted @ 2012-10-04 16:01 tmeteorj 阅读(193) 评论(0) 推荐(0)
 
POJ 2010
摘要: 题意:奶牛学校招生,c头奶牛报名,要选n头(n为奇数),学校是义务制,所以每头奶牛的学费都由学校负责。每头奶牛都由自己的考试分数和它需要花的学费,学校总共有f的资金,问合法招生方案中中间分数(即排名第(n+1)/2)最高的是多少。题解:先将所有的奶牛按照分数由高到低排序,假设k是招的奶牛中排名中间的那头,按照排序可知,[1,k-1]中的奶牛必定被招了(n-1)/2头,[k+1,c]中也必定被招了(n-1)/2头,而且无论招的是谁,分数是怎么样,最后影响结果的都只是k的分数。于是,可以预处理dpl[i]代表[1,i]头牛中选出(n-1)/2头牛的最小花费,dpr[i]代表[i,c]头牛中选出(n 阅读全文
posted @ 2012-10-04 15:36 tmeteorj 阅读(1576) 评论(1) 推荐(2)
 
POJ 1059
摘要: 题意:模拟大富翁游戏,给出骰子会掷出的点数,问最后谁会赢。题解:模拟。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int ran[1005],id,top; 6 int getnext() 7 { 8 return ran[id++]; 9 }10 int pos[10],to[105],flag[105];11 bool res[105];12 int main()13 {14 int x,y;15 top=0 阅读全文
posted @ 2012-10-04 15:04 tmeteorj 阅读(347) 评论(0) 推荐(0)
 
POJ 3282
摘要: 题意:船载车过河,车有长度,船也有长度,给出每辆车来的顺序以及到达的岸,问最少渡几次。题解:贪心,能装多少装多少,每次都尽可能多装。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<list> 5 using namespace std; 6 list<int> ql,qr; 7 int main() 8 { 9 int T;10 for(scanf("%d",&T);T;T--)11 {12 阅读全文
posted @ 2012-10-04 14:30 tmeteorj 阅读(172) 评论(0) 推荐(0)
 
POJ 3639
摘要: 题意:初始有加拿大的$1000,给出每天一个美国美元与加拿大美元的兑换率,每次兑换需要花费3%的手续费,并且还会把小于美分的给省去,问最后最多有多少加拿大美元。题解:dp[i][0]为第i天最多有多少加拿大美元,dp[i][1]为第i天最多有多少美国美元,dp[i][0]=max(dp[i-1][0],update(dp[i-1][1]*per*0.97)); dp[i][1]=max(update(dp[i-1][0]/per*0.97),dp[i-1][1]);update是舍去美分以下的数。View Code 1 #include<cstdio> 2 #inclu... 阅读全文
posted @ 2012-10-04 13:40 tmeteorj 阅读(195) 评论(0) 推荐(0)
 
 

公告


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