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

2012年9月26日

POJ 3279
摘要: 题意:黑白的板,每次选择一个十字形翻转(十字板内黑白互换,若是边界则不管),求最小将原图变为全白的策略。题解:枚举第一行翻转情况,2^c,然后验证,由于第一行确定了,后面就可以跟着确定了。View Code 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 int map[20][20]; 6 int hit[20][20],ahit[20][20]; 7 int ans,r,c; 8 const int inf=1<<30; 阅读全文
posted @ 2012-09-26 21:19 tmeteorj 阅读(1779) 评论(0) 推荐(0)
 
POJ 2657
摘要: 题意:有长度为n的环,环上有m个坏点,目标在z位置,从1出发,每次跳k步,最后到达z,问最小的k是多少。题解:1、暴力枚举,我没试过,但有人这样过了。 2、考虑目标z,假设跳了m圈,最后跳到z,则有(z-1+m*n)≡0 (mod k),如果(z-1)%k==0,直接检验小于z的坏点是否会猜到,否则,m*n≡(z-1)%k (mod k),用模线性方程可以求出m,考虑坏点,分为两类,一类坏点的坐标小于z,人会从上面跨过m+1次,另一类坏点坐标大于z,人会从上面跨过m次。 对于任意一个坏点a,如果在某一次踩在了它上面,就存在(a-1)*(a-1+n)*(a-1+2*n)*(a-1+3... 阅读全文
posted @ 2012-09-26 20:53 tmeteorj 阅读(216) 评论(0) 推荐(0)
 
POJ 1252
摘要: 题意:给6种不同面额硬币,求组成[1,100]中数的平均需要硬币与最多需要硬币数,可以通过减法获得,比如有1、4两种硬币,凑成3可以用4-1两个硬币完成,而不是1+1+1三个硬币。题解:背包问题,由于可以减,还需要反过来dp一遍,值得注意的是上界需要设成2000才行。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int dp[2050]; 6 void update(int v) 7 { 8 if(v>0) 阅读全文
posted @ 2012-09-26 19:38 tmeteorj 阅读(317) 评论(0) 推荐(0)
 
POJ 1240
摘要: 题意:给定一颗多叉树(<=20)的先序和后序遍历结果,求这种树共有多少。题解:考虑产生相同先序遍历和后序遍历的两种树,S和T,他们每个相同结点对应的孩子数目应该相等,因为假如S某个结点有s个孩子,他们在先序和后序遍历中的顺序是一致的,要想两棵树先序遍历与后序遍历一致,则他们每一个结点的孩子都应该有这种特点。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 typedef long long ll; 6 ll c[ 阅读全文
posted @ 2012-09-26 18:51 tmeteorj 阅读(387) 评论(0) 推荐(0)
 
POJ 2887
摘要: 题意:在字符串中插入字符,问第i个字符是谁题解:块状链表,不知为什么splay超时= =!View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<algorithm> 5 using namespace std; 6 const int maxn=1005000; 7 int bs,top; 8 struct Block 9 {10 int size,next;11 char s[3000];12 void push_back(char ch)13 阅读全文
posted @ 2012-09-26 11:23 tmeteorj 阅读(362) 评论(0) 推荐(0)
 
 

公告


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