摘要: Message 思路 一开始的思路就是暴力匹配,数据只有 $2000$ 最大嘛,先是把s串作为文本串,u作为模式串取匹配,过了样例交一发,看着测评机跑到了25,突然就停了,果真没这么简单,wa了一发,然后想一下,如果两个互换位置再匹配一次行不行,没想到还真过了。 乱搞过了,还是把道理给搞清楚吧。 首 阅读全文
posted @ 2020-05-04 14:47 lifehappiness 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Find Pair 思路 排一下序然后枚举计数就行了,不是挺简单的嘛。 这是我以为能过的代码,没想到$Wrong\ answer\ on\ test\ 3$,还是只能过样例。 阅读全文
posted @ 2020-05-04 12:10 lifehappiness 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Another Problem on Strings 思路 题目的这一句话提示着我要用binary_search,没想到还真是, 这题考察的就是两个知识点,前缀和以及二分查找,二分查找用STL解决了,前缀和也简单,接下来就是两者组合了。 我们假定当前位置的前缀和是 $sum[i]$,我们想办法从前面 阅读全文
posted @ 2020-05-04 10:33 lifehappiness 阅读(96) 评论(0) 推荐(0) 编辑
摘要: Count The Blocks " Count The Blocks 题目链接 " 思路 首先打表出来,发现了一个规律 $num[1] = 10, num[2] = 180$,这里的数组标记是反的 发现假定前 $n 1$个num已经求得,我们可以得到 $num[n] = n 10^{n} \sum 阅读全文
posted @ 2020-05-03 18:57 lifehappiness 阅读(94) 评论(0) 推荐(0) 编辑
摘要: Two Arrays " Two Arrays 题目链接 " 思路 我们可以把两个序列链接起来,有 $a_1 using namespace std; typedef long long ll; const int mod = 1e9 + 7; int dp[30][1010], n, m; int 阅读全文
posted @ 2020-05-03 18:21 lifehappiness 阅读(63) 评论(0) 推荐(0) 编辑
摘要: Eugene and an array " Eugene and an array 题目链接 " 思路 考察的是前缀和的应用,我们假定$sum_i == sum_j$哪么一定有$\sum\limits_{k = i + 1} ^ {j}a_k= 0$ 我们从$1 n$每次计算符合要求的以当前的点为终 阅读全文
posted @ 2020-04-30 15:26 lifehappiness 阅读(103) 评论(0) 推荐(0) 编辑
摘要: Almost All Divisors " Almost All Divisors 题目链接 " 思路 这题稍微简单,直接模拟,我们知道 $x$ 一定是排序后的 $a[1] a[n]$ 所以直接排序,然后再找一遍 $x$ 的因子,最后比对这两个因子数组是不是一样的,一样就输出 $x$,否者就输出 $ 阅读全文
posted @ 2020-04-29 15:57 lifehappiness 阅读(50) 评论(0) 推荐(0) 编辑
摘要: Prime Graph " Prime Graph 题目链接 " 思路 先打个表找出1e6之内的所有质数,然后我们可以显然的发现好像一定是有解的因为 $n C_n ^2$ 之间一定存在一个质数。再通过简单的发现$n n + n / 2$之间也存在一个质数,于是这道题目就变得非常简单了。先打表,绕着所 阅读全文
posted @ 2020-04-29 15:56 lifehappiness 阅读(120) 评论(0) 推荐(0) 编辑
摘要: p binary " p binary 题目链接 " 错误思路 先说一下我一开始样例都过不了的思路把,由于 $n using namespace std; typedef long long ll; const int N = 55; ll a[N], n, p; inline ll lowbit( 阅读全文
posted @ 2020-04-29 15:55 lifehappiness 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Game with Chips " Game with Chips 题目链接 " 思路 一开始以为还要用bfs或者dfs来写,然后仔细想一想,div2的C题应该没这么复杂吧。果然,这就是一道脑洞题,我们发现题目给的数据是步数小于等于 $2nm$ 这足够走两遍完整的地图了,于是有了下面的做法。 我们把 阅读全文
posted @ 2020-04-29 15:54 lifehappiness 阅读(78) 评论(0) 推荐(0) 编辑