2014年7月30日
摘要: dp 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 struct node { 8 int x,y,h; 9 void init (int nx,int ny,int nh){1... 阅读全文
posted @ 2014-07-30 11:39 gfc 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 动态规划题意可以理解为两个人同时从最左点出发,沿着两条不同的路径走到最右点(除了起点和终点每个点走且仅走一次)状态 dp[i][j]指当前两人分别走到i,j点。且设i>j;则有:dp[i+1][i]=min (dp[i+1][i],dp[i][j]+dist[i][i+1]); dp[i+1]... 阅读全文
posted @ 2014-07-30 09:49 gfc 阅读(382) 评论(0) 推荐(0) 编辑
  2014年7月28日
摘要: 贪心+优先队列+问题分解对x,y 分开处理当 xl 2 #include 3 #include 4 #include 5 using namespace std; 6 7 struct node { 8 int l,r; 9 int id;10 friend bool... 阅读全文
posted @ 2014-07-28 16:07 gfc 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 每次从最底部开始处理,如果不是最大值,则把最大值翻到底部。这就是最优解。原理自己模拟一下就好。。。注意半径不是从1开始。数据处理要仔细。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int m... 阅读全文
posted @ 2014-07-28 08:48 gfc 阅读(126) 评论(0) 推荐(0) 编辑
  2014年7月27日
摘要: 看完题解还wa了老半天才ac = =!囧rz 给大牛门跪了因为本题求的是最后状态的种数,设最终翻到正面为1,反面为0:因为每次翻牌的选择自由,所以一定范围内,翻到正面的牌数相差2的状态都可以取到;(假设当前状态为i 个1,可以用一次翻到1的机会把另一个翻到1的牌翻到0;这样状态就是i-2,相差2了;... 阅读全文
posted @ 2014-07-27 16:06 gfc 阅读(157) 评论(0) 推荐(0) 编辑
  2014年7月25日
摘要: 排序首先,看到这种题如果确定是排序,第一反应就是排序条件:Ei/Ki ,或者Ki/Ei。。。(注意浮点数)对于两个题i,j;判断这两个题的顺序方式如下:设两个题之前所有题时间和为 tt;则 若i 在j 前:score(i)=Ki*(tt+Ei)+Kj*(tt+Ei+Ej); j 在i 前:sco... 阅读全文
posted @ 2014-07-25 08:58 gfc 阅读(138) 评论(0) 推荐(0) 编辑
  2014年7月23日
摘要: 贪心,排序,二分。。。对x排序。对于每个task,先把时间满足它的机器放入集合中,在二分找能处理它的最小等级的机器。#include #include #include #include #include using namespace std;const int maxn = 200010;str... 阅读全文
posted @ 2014-07-23 15:30 gfc 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 费马小定理打表后可知,ball的值为1~p-1的循环;且只有第p-1个球不为0;所以,只有k/(p-1)个球不为0,且它们的值相等。 1 #include 2 using namespace std; 3 4 int main (){ 5 int k,p; 6 while (ci... 阅读全文
posted @ 2014-07-23 10:05 gfc 阅读(115) 评论(0) 推荐(0) 编辑
  2014年7月22日
摘要: 带状态的bfs用一个数(ks)来表示状态-当前连续穿越的障碍数;step表示当前走过的步数;visit数组也加一个状态; 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int max... 阅读全文
posted @ 2014-07-22 16:58 gfc 阅读(607) 评论(0) 推荐(0) 编辑
摘要: 二叉树? 怒水~~注意一下查询与x值的对应关系就好~ 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main (){ 7 char s[1000]; 8 int a[10],b[10]; 9 ... 阅读全文
posted @ 2014-07-22 16:22 gfc 阅读(164) 评论(0) 推荐(0) 编辑