上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 27 下一页
摘要: 挺水的,我是用n个set分别存下n个用户的广告,然后对于遍历一次所有用户的广告处理出ans数组,输出即可。/* * hdu4020/win.cpp * Created on: 2012-11-10 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue 阅读全文
posted @ 2012-11-12 16:30 moonbay 阅读(166) 评论(0) 推荐(0)
摘要: 这题还是挺好的,想了好久才想出做法。做法的大体思想其实就是暴力删点,用了一个布尔数组(deleted)来记录在执行一个请求前某点是否已被删除(所以在点结构体中加了一个变量id以唯一标识一个点)。我是用了两个链表存了两份点(lx, ly),一份先按x再按y排序,另一份先按y再按x排序。然后用一个mapx存下lx中不同x值开始的位置。(同理得mapy)。对于一个删除x=d的请求,可以直接从mapx中读出x=d在链表中的起始位置,然后一个个地删,一边删一边记录在deleted数组中就可以了。同理可以处理y=d的情况。这题最让我记忆深刻的地方是我在打代码的时候有个地方犯了一个小错误死循环了没输出结果, 阅读全文
posted @ 2012-11-12 16:27 moonbay 阅读(184) 评论(0) 推荐(0)
摘要: 这题看完本来以为是找规律的,可找了半天也没找出啥规律,翻了一下解题报告,说是搜索加剪枝,学了一下,就过了。/* * hdu4016/win.cpp * Created on: 2012-11-9 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue& 阅读全文
posted @ 2012-11-09 14:45 moonbay 阅读(132) 评论(0) 推荐(0)
摘要: 这题刚开始是没思路,后来觉得是DP,连DP方程都想出来,还考虑了各种优化方法,可是觉得实现难度有点大,所以先查解题报告。。。。结果一查,网上有人的代码异常简单,只有几行代码,所以马上意识到考虑复杂了,转而找规律,才算了几组,规律就出来了,就是1/(m*k+1+k)。so easy?/* * hdu4015/win.cpp * Created on: 2012-11-8 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#inc 阅读全文
posted @ 2012-11-09 00:12 moonbay 阅读(224) 评论(0) 推荐(0)
摘要: 类似于骨牌问题。我的做法就是首先看能不能横着排满,然后看能不能竖着排满,都不行的话就考虑一些横着排,一些竖着排,看能不能满足要求,最后也就转化为求ax+by=n有没有非负解的问题。可是我用扩展欧几里得打了,超时,无奈只能纯枚举了,枚举放1个、2个、3个...直到放不下为止。这说明测试数据很操蛋。/* * hdu2965/win.cpp * Created on: 2012-11-4 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath& 阅读全文
posted @ 2012-11-06 21:42 moonbay 阅读(231) 评论(0) 推荐(0)
摘要: 这题本来以为得DFA的,仔细审题以后发现,题目说每个关键字前4个字母不同(这意味着每个关键字结束的节点都是不同的),而且长度不超过60,马上醒悟,只要用所有的关键字建一棵Trie树,然后把主串跑一遍就可以了,复杂度为主串长度*60,肯定能过啊。。。/* * hdu1277/win.cpp * Created on: 2012-11-6 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime> 阅读全文
posted @ 2012-11-06 19:43 moonbay 阅读(171) 评论(0) 推荐(0)
摘要: 这题本来完全没思路的,后来想一想,要不打个表找找规律吧。于是打了个表,真找到规律了。。。打表的代码如下:int n;void dfs(int x1, int y1, int x2, int y2) { if (y1 + y2 <= n) { dfs(x1, y1, x1 + x2, y1 + y2); printf("%d/%d\n", x1 + x2, y1 + y2); dfs(x1 + x2, y1 + y2, x2, y2); }}void print_farey(int n) { printf("0/1\n"); df... 阅读全文
posted @ 2012-11-05 22:14 moonbay 阅读(354) 评论(0) 推荐(0)
摘要: 这题是大水题。不过我用了一种比较诡异的写法,也不是为了装逼,主要是为了熟悉一下bitset的用法以及数据类型的转换。/* * hdu2207/win.cpp * Created on: 2012-11-5 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <q 阅读全文
posted @ 2012-11-05 14:13 moonbay 阅读(164) 评论(0) 推荐(0)
摘要: 像这种直接调用STL函数就能出结果的题,现在应该不会再出了吧。。。/* * hdu3283/win.cpp * Created on: 2012-11-4 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include <set& 阅读全文
posted @ 2012-11-04 18:30 moonbay 阅读(165) 评论(0) 推荐(0)
摘要: 这题考查的内容还是比较多的,不过仅限于思路,如果模板准备充足的话还是很快的。这题首先要对问题进行转换。题目是给一个L,问由8组成的最短的能被L整除的数。不妨设长度为x。那么就是要求最小的x使8*[1+10+10^2+...+10^(x-1)] ≡ 0 (mod L)。也就是求最小的x使(8/9)*(10^x-1) ≡ 0 (mod L)。也就是求最小的x使10^x ≡ 1 (mod y),其中y = 9 * L / gcd(8, 9 * L)。于是存在满足题意的x当且仅当gcd(10, y) = 1。对于有解的情况,显然,x = φ(y)时,10^φ(y) ≡ 1 (mod y)成立,且每个符 阅读全文
posted @ 2012-11-04 17:39 moonbay 阅读(234) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 27 下一页