自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(60)
  • 收藏
  • 关注

原创 HDU 4870 Rating(概率DP)

Problem DescriptionA little girl loves programming competition very much. Recently, she has found a new kind of programming competition named "TopTopTopCoder". Every user who has registered in "TopT...

2019-08-08 21:29:20 327

原创 GYM 101002C Greetings!(状压DP)

Your greeting card company makes unique greeting cards. The sizes of these greeting cards vary widely because of the whims of card designers. There are a lot of different types of cards, and each has ...

2019-08-08 10:08:00 258

原创 BZOJ 3143 [Hnoi2013]游走(概率DP)

Description一个无向连通图,顶点从1编号到N,边从1编号到M。小Z在该图上进行随机游走,初始时小Z在1号顶点,每一步小Z以相等的概率随机选 择当前顶点的某条边,沿着这条边走到下一个顶点,获得等于这条边的编号的分数。当小Z 到达N号顶点时游走结束,总分为所有获得的分数之和。现在,请你对这M条边进行编号,使得小Z获得的总分的期望值最小。Input第一行是正整数N和M,分别表...

2019-08-07 21:37:41 551

原创 POJ 3974 Palindrome(Manacher)(板子题)

DescriptionAndy the smart computer science student was attending an algorithms class when the professor asked the students a simple question, "Can you propose an efficient algorithm to find the leng...

2019-08-03 15:24:25 158

原创 UVALive 5970 An Average Game(莫队)

5970 An Average GameAlice and Bob has just learned how to find average of some numbers. They got really excited and decided to come up with a game about finding average. The game works like this, at...

2019-08-03 15:12:46 120

原创 HDU 1556 Color the ball(分块)(板子题)

Color the ballTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 24404 Accepted Submission(s): 11853Problem DescriptionN个气球排成一排,从左到右依次编号为1,...

2019-08-03 15:01:09 112

原创 POJ 3321 Apple Tree(DFS序+树状数组)

DescriptionThere is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.The...

2019-08-03 14:51:56 152

原创 HDU 2222 Keywords Search(AC自动机)(板子题)

In the modern time, Search engine came into the life of everybody like Google, Baidu, etc.Wiskey also wants to bring this feature to his image retrieval system.Every image have a long description,...

2019-08-03 10:54:05 125

原创 HDU 5692 Snacks(DFS序+线段树)

Problem Description百度科技园内有个零食机,零食机之间通过条路相互连通。每个零食机都有一个值,表示为小度熊提供零食的价值。由于零食被频繁的消耗和补充,零食机的价值会时常发生变化。小度熊只能从编号为0的零食机出发,并且每个零食机至多经过一次。另外,小度熊会对某个零食机的零食有所偏爱,要求路线上必须有那个零食机。为小度熊规划一个路线,使得路线上的价值总和最大。Inp...

2019-08-03 10:49:08 141

原创 求逆元

方法一:扩展欧几里得a∗b≡1(modp) ;a∗b+k∗p=1 ;LL exgcd(LL a,LL b,LL &x,LL &y)//扩展欧几里得算法 { if(b==0) { x=1,y=0; return a; } LL ret=exgcd(b,a%b,y,x); y-=a/b*x; ...

2019-05-24 10:51:05 271

原创 HDU 2204 Eddy's爱好(容斥原理)

Ignatius 喜欢收集蝴蝶标本和邮票,但是Eddy的爱好很特别,他对数字比较感兴趣,他曾经一度沉迷于素数,而现在他对于一些新的特殊数比较有兴趣。这些特殊数是这样的:这些数都能表示成M^K,M和K是正整数且K>1。正当他再度沉迷的时候,他发现不知道什么时候才能知道这样的数字的数量,因此他又求助于你这位聪明的程序员,请你帮他用程序解决这个问题。为了简化,问题是这样的:给你一个正整数N,...

2019-05-19 20:17:52 216

原创 HDU 2841 Visible Trees (容斥原理)

There are many trees forming a m * n grid, the grid starts from (1,1). Farmer Sherlock is standing at (0,0) point. He wonders how many trees he can see.If two trees and Sherlock are in one line, Farm...

2019-05-19 20:06:52 160

原创 中国剩余定理

已知:Num%m[1]=a[1];Num%m[2]=a[2];Num%m[3]=a[3];︙         ︙        ︙Num%m[n]=a[n];求解Num的最小整数解 :#include <bits/stdc++.h>using namespace std;typedef long long LL;const int maxn = ...

2019-02-21 17:08:08 132

原创 POJ 1006 Biorhythms (中国剩余定理)

Some people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have periods ...

2019-02-21 15:56:02 144

原创 Codeforces 1011E Border (贝祖定理)

Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the...

2019-02-21 09:53:04 261

原创 POJ 2115 C Looooops (扩展欧几里得求解线性同余方程)

A Compiler Mystery: We are given a C-language style for loop of typefor (variable = A; variable != B; variable += C) statement;I.e., a loop which starts by setting variable to value A and whi...

2019-02-20 15:27:01 169

原创 Codeforces 719E Sasha and Array (线段树+矩阵快速幂)

Sasha has an array of integers a1, a2, ..., an. You have to perform m queries. There might be queries of two types:1 l r x — increase all integers on the segment from l to r by values x; 2 l r — fi...

2019-02-20 10:46:10 188

原创 Ural 1009 K-based Numbers. Version 3 (DP+矩阵快速幂+快速乘)

Let’s consider K-based numbers, containing exactly N digits. We define a number to be valid if its K-based notation doesn’t contain two successive zeros. For example:1010230 is a valid 7-digit numbe...

2019-02-19 14:36:40 162

原创 HDU 5015 233 Matrix (矩阵快速幂)

In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. I...

2019-02-18 17:35:31 177

原创 HDU 4291 A Short problem (矩阵快速幂+循环节)

  According to a research, VIM users tend to have shorter fingers, compared with Emacs users.  Hence they prefer problems short, too. Here is a short one:  Given n (1 <= n <= 10 18), You shoul...

2019-02-18 11:48:35 163

原创 UVA 10006 Carmichael Numbers (快速幂取模+素数筛)(卡迈克尔数)

Sample Input17291756111094310Sample OutputThe number 1729 is a Carmichael number.17 is normal.The number 561 is a Carmichael number.1109 is normal.431 is normal. 卡迈克尔数:对于...

2019-02-18 11:28:15 271

原创 POJ 1417 True Liars (种类并查集+DP+路径回溯)

After having drifted about in a small boat for a couple of days, Akira Crusoe Maeda was finally cast ashore on a foggy island. Though he was exhausted and despaired, he was still fortunate to remember...

2019-02-17 20:56:20 182

原创 POJ 2912 Rochambeau (暴力枚举+带权并查集)

N children are playing Rochambeau (scissors-rock-cloth) game with you. One of them is the judge. The rest children are divided into three groups (it is possible that some group is empty). You don’t kn...

2019-02-17 15:52:27 156

原创 POJ 1733 Parity game (map映射+带权并查集)

Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequence from the t...

2019-02-17 15:45:56 122

原创 POJ 1984 Navigation Nightmare (双向带权并查集)

Farmer John's pastoral neighborhood has N farms (2 <= N <= 40,000), usually numbered/labeled 1..N. A series of M (1 <= M < 40,000) vertical and horizontal roads each of varying lengths (1 ...

2019-02-17 15:40:45 171

原创 POJ 3279 Fliptile (暴力枚举+DFS)

p.s. 黑白棋反转问题Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in which they manipulate an M × N grid (1 ≤ M ≤ ...

2019-01-19 08:23:23 260

原创 线段树(区间修改)

#include <bits/stdc++.h>using namespace std;int Sum[200001],Add[200001];//Add懒惰标记int Num[50001]={0,1,2,3,4,5,6};void create(int l,int r,int rt){ if(l==r) { Sum[rt]=Num[l...

2018-12-30 13:44:48 3806

原创 数组计算机

p.s. 线段树基本操作(点修改)数组计算机Time Limit: 1000 ms Memory Limit: 65536 KiBProblem DescriptionbLue 有一个神器的机器,这个机器可以读入一个数组,并按照用户要求快速地进行数组的处理和计算,它支持如下两种操作:操作 1:把数组中第 p 个元素的值增加 v。 操作 2:计算数组中 [l, r] 区间内所有...

2018-12-29 18:46:30 452

原创 字典树

字典树Time Limit: 1000 ms Memory Limit: 65536 KiBProblem Description遇到单词不认识怎么办? 查字典啊,已知字典中有n个单词,假设单词都是由小写字母组成。现有m个不认识的单词,询问这m个单词是否出现在字典中。Input含有多组测试用例。第一行输入n,m (n>=0&&n<=100000&...

2018-12-27 22:12:01 195

原创 数据结构实验之排序四:寻找大富翁

p.s. 堆排or快排数据结构实验之排序四:寻找大富翁Time Limit: 200 ms Memory Limit: 512 KiBProblem Description2015胡润全球财富榜调查显示,个人资产在1000万以上的高净值人群达到200万人,假设给出N个人的个人资产值,请你快速找出排前M位的大富翁。Input首先输入两个正整数N( N ≤ 10^6)和M(M ...

2018-12-27 20:22:16 120

原创 数据结构实验之查找二:平衡二叉树

数据结构实验之查找二:平衡二叉树Time Limit: 400 ms Memory Limit: 65536 KiBProblem Description根据给定的输入序列建立一棵平衡二叉树,求出建立的平衡二叉树的树根。Input输入一组测试数据。数据的第1行给出一个正整数N(n <= 20),N表示输入序列的元素个数;第2行给出N个正整数,按数据给定顺序建立平衡二叉树。...

2018-12-22 22:04:07 198

原创 数据结构实验之查找一:二叉排序树

数据结构实验之查找一:二叉排序树Time Limit: 400 ms Memory Limit: 65536 KiBProblem Description对应给定的一个序列可以唯一确定一棵二叉排序树。然而,一棵给定的二叉排序树却可以由多种不同的序列得到。例如分别按照序列{3,1,4}和{3,4,1}插入初始为空的二叉排序树,都得到一样的结果。你的任务书对于输入的各种序列,判断它们是否能...

2018-12-21 22:44:48 159

原创 二叉排序树

p.s. 前序+中序即可确立唯一树二叉排序树Time Limit: 1000 ms Memory Limit: 65536 KiBProblem Description二叉排序树的定义是:或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值; 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值; 它的左、右子树也分别为...

2018-12-21 21:48:39 98

原创 树结构练习——排序二叉树的中序遍历

树结构练习——排序二叉树的中序遍历Time Limit: 1000 ms Memory Limit: 65536 KiBProblem Description在树结构中,有一种特殊的二叉树叫做排序二叉树,直观的理解就是——(1).每个节点中包含有一个关键值 (2).任意一个节点的左子树(如果存在的话)的关键值小于该节点的关键值 (3).任意一个节点的右子树(如果存在的话)的关键值大于该...

2018-12-21 21:46:11 202

原创 数据结构实验之二叉树一:树的同构

数据结构实验之二叉树一:树的同构Time Limit: 1000 ms Memory Limit: 65536 KiBProblem Description给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。 图1...

2018-12-20 22:11:00 117

原创 数据结构实验之二叉树的建立与遍历

数据结构实验之二叉树的建立与遍历Time Limit: 1000 ms Memory Limit: 65536 KiBProblem Description       已知一个按先序序列输入的字符序列,如abc,,de,g,,f,,,(其中逗号表示空节点)。请建立二叉树并按中序和后序方式遍历二叉树,最后求出叶子节点个数和二叉树深度。 Input 输入一个长度小于50个字符...

2018-12-20 21:11:00 114

原创 数据结构实验之二叉树七:叶子问题

数据结构实验之二叉树七:叶子问题Time Limit: 1000 ms Memory Limit: 65536 KiBProblem Description已知一个按先序输入的字符序列,如abd,,eg,,,cf,,,(其中,表示空结点)。请建立该二叉树并按从上到下从左到右的顺序输出该二叉树的所有叶子结点。Input 输入数据有多行,每一行是一个长度小于50个字符的字符串。...

2018-12-20 21:00:37 114

原创 数据结构实验之二叉树八:(中序后序)求二叉树的深度

数据结构实验之二叉树八:(中序后序)求二叉树的深度Time Limit: 1000 ms Memory Limit: 65536 KiBProblem Description已知一颗二叉树的中序遍历序列和后序遍历序列,求二叉树的深度。Input输入数据有多组,输入T,代表有T组数据。每组数据包括两个长度小于50的字符串,第一个字符串表示二叉树的中序遍历,第二个表示二叉树的后序遍...

2018-12-20 20:43:31 128

原创 数据结构实验之二叉树三:统计叶子数

数据结构实验之二叉树三:统计叶子数Time Limit: 1000 ms Memory Limit: 65536 KiBProblem Description已知二叉树的一个按先序遍历输入的字符序列,如abc,,de,g,,f,,, (其中,表示空结点)。请建立二叉树并求二叉树的叶子结点个数。Input连续输入多组数据,每组数据输入一个长度小于50个字符的字符串。Outpu...

2018-12-20 20:16:44 125

原创 求二叉树的层次遍历

求二叉树的层次遍历Time Limit: 1000 ms Memory Limit: 65536 KiBProblem Description已知一颗二叉树的前序遍历和中序遍历,求二叉树的层次遍历。Input输入数据有多组,输入T,代表有T组测试数据。每组数据有两个长度小于50的字符串,第一个字符串为前序遍历,第二个为中序遍历。Output每组输出这颗二叉树的层次遍历。...

2018-12-20 20:15:10 143

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除