自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Clairewd’s message 密文转换(扩展KMP)

Clairewd is a member of FBI. After several years concealing in BUPT, she intercepted some important messages and she was preparing for sending it to ykwd. They had agreed that each letter of these mes

2018-01-31 17:02:04 310

原创 CodeForces - 908C New Year and Curling

Carol is currently curling.She has n disks each with radius r on the 2D plane. Initially she has all these disks above the line y = 10100.She then will slide the disks towards the line y = 0 o

2018-01-30 13:55:01 143

原创 One-Dimensional Battle Ships CodeForces - 567D

Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting ofn square cells (that is, on a 1 × n table).At the beginning of the game Alice p

2018-01-30 13:25:27 214

原创 Bellovin HDU - 5748

Peter has a sequence a1,a2,...,an and he define a function on the sequence -- F(a1,a2,...,an)=(f1,f2,...,fn), where fi is the length of the longest increasing subsequence ending with ai.

2018-01-30 12:07:09 200

原创 Seek the Name, Seek the Fame

The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies. They seek the name, and at the same time seek th

2018-01-29 21:23:55 183

原创 Count the string

It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this string. For example:s: "ab

2018-01-29 20:30:51 708 2

原创 Period (KMP)

For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2

2018-01-29 20:07:35 223

原创 Power Strings

Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-

2018-01-29 18:52:30 632

原创 Cyclic Nacklace

CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed and thinking about how to

2018-01-29 18:15:33 155

原创 剪花布条(KMP算法)

一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢?Input 输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。如果遇见#字符,则不再进行工作。Ou

2018-01-29 17:23:26 530

原创 Rain on your Parade (Hopcroft-Karp算法)

You’re giving a party in the garden of your villa by the sea. The party is a huge success, and everyone is here. It’s a warm, sunny evening, and a soothing wind sends fresh, salty air from the sea. Th

2018-01-29 10:14:51 354

原创 HDU-1350 Taxi Cab Scheme(最小路径覆盖)

Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a cab as soon as possible, ther

2018-01-28 12:06:28 184

转载 二分图之最小路径覆盖

1. 最小边覆盖最小边覆盖:边覆盖集:通俗地讲,所谓边覆盖集,就是G中所有的顶点都是E*中某条边的邻接顶点(边覆盖顶点),一条边只能覆盖2个顶点。注意:在无向图中存在用尽量少的边去“覆盖”住所有的顶点(注意:单独一个点没有与它相连的边,也算作一次边去覆盖这个点),所以边覆盖集有极小与最小的区别。极小边覆盖:若边覆盖E*中的任何真子集都不是边覆盖集,则称E*是极小边覆盖集。最小边

2018-01-28 10:53:12 775

原创 Treasure Exploration (最少路径覆盖+传递闭包)

Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored treasure? If you never have such experiences, you would never know

2018-01-28 10:51:23 192

原创 Hopcroft-Karp算法

Hopcroft-Karp算法该算法由John.E.Hopcroft和Richard M.Karp于1973提出,故称Hopcroft-Karp算法。原理为了降低时间复杂度,可以在增广匹配集合M时,每次寻找多条增广路径。这样就可以进一步降低时间复杂度,可以证明,算法的时间复杂度可以到达O(n^0.5*m),虽然优化不了多少,但在实际应用时,效果还是很明显的。基本算法该算法主要是对匈牙利算法的优化,...

2018-01-27 21:31:40 1122

原创 Asteroids (最小点覆盖)

Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 <= K <= 10,000), which are conveniently locate

2018-01-27 18:10:46 311

原创 HDU-3829 Cat VS Dog(最大独立集)

The zoo have N cats and M dogs, today there are P children visiting the zoo, each child has a like-animal and a dislike-animal, if the child's like-animal is a cat, then his/hers dislike-animal must b...

2018-01-27 17:42:43 199

原创 Girls and Boys (最大独立集)

In the second year of the university somebody started a study on the romantic relations between the students. The relation "romantically involved" is defined between one girl and one boy. For the stud

2018-01-27 17:39:46 248

原创 Bubble Sort HDU - 5775 (树状数组)

P is a permutation of the integers from 1 to N(index starting from 1).Here is the code of Bubble Sort in C++. for(int i=1;i<=N;++i) for(int j=N,t;j>i;—j) if(P[j-1] > P[j])

2018-01-27 15:37:16 217

原创 The Moving Points HDU - 4717 (三分)

There are N points in total. Every point moves in certain direction and certain speed. We want to know at what time that the largest distance between any two points would be minimum. And also, we requ

2018-01-27 12:10:47 224

原创 4个数和为0 51Nod - 1267 (二分法)

给出N个整数,你来判断一下是否能够选出4个数,他们的和为0,可以则输出"Yes",否则输出"No"。Input 第1行,1个数N,N为数组的长度(4 第2 - N + 1行:Ai(-10^9 iOutput 如果可以选出4个数,使得他们的和为0,则输出"Yes",否则输出"No"。 Sample Input 5-11-524Sample Output Yes

2018-01-27 10:56:55 158

原创 Appleman and Card Game

Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choosek cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards.

2018-01-27 10:15:02 214

原创 C++版大数据加减乘法

#include&lt;iostream&gt;#include&lt;string&gt;#include&lt;vector&gt;using namespace std;string sum(string ans,string b){ if(ans.length()&lt;b.length()) ans.swap(b); for(int i=ans.length()-1,j=b...

2018-01-26 10:00:21 884

原创 Catch(HDU2478)

Problem DescriptionA thief is running away!We can consider the city where he locates as an undirected graph in which nodes stand for crosses and edges stand for streets. The crosses are labeled fr

2018-01-25 16:31:32 258

原创 图论之二分图的判定

二分图定义:简而言之,就是顶点集V可分割为两个互不相交的子集,并且图中每条边依附的两个顶点都分属于这两个互不相交的子集,两个子集内的顶点不相邻。二分图是这样一个图:有两顶点集且图中每条边的的两个顶点分别位于两个顶点集中,每个顶点集中没有边直接相连接。判定方法——染色法:       开始对任意一未染色的顶点染色,之后判断其相邻的顶点中,若未染色则将其染上和相邻顶点不同的颜色,

2018-01-25 15:38:08 410

原创 Funky Numbers CodeForces - 192A

As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as, wherek is some positive integer), and the coolest numbers are tho

2018-01-24 18:26:20 287

原创 System of Equations CodeForces - 214A

Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved

2018-01-24 18:09:45 223

原创 Interesting drink

Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought inn different shops in the city

2018-01-24 18:07:49 229

原创 Multiply game

Tired of playing computer games, alpc23 is planning to play a game on numbers. Because plus and subtraction is too easy for this gay, he wants to do some multiplication in a number sequence. After pla

2018-01-24 18:06:32 309

原创 矩阵中不重复的元素

一个m*n的矩阵。该矩阵的第一列是a^b,(a+1)^b,.....(a + n - 1)^b第二列是a^(b+1),(a+1)^(b+1),.....(a + n - 1)^(b+1).......第m列是a^(b + m - 1),(a+1)^(b + m - 1),.....(a + n - 1)^(b + m - 1)(a^b表示a的b次方)下面是一

2018-01-24 10:35:40 272

原创 正整数分组

将一堆正整数分为2组,要求2组的和相差最小。 例如:1 2 3 4 5,将1 2 4分为1组,3 5分为1组,两组和相差1,是所有方案中相差最少的。Input 第1行:一个数N,N为正整数的数量。第2 - N+1行,N个正整数。(N Output 输出这个最小差 Sample Input 512345Sample Output 1#includ

2018-01-24 10:34:06 139

原创 骨牌覆盖

在2*N的一个长方形方格中,用一个1*2的骨牌排满方格。问有多少种不同的排列方法。例如:2 * 3的方格,共有3种不同的排法。(由于方案的数量巨大,只输出 Mod 10^9 + 7 的结果)Input 输入N(N Output 输出数量 Mod 10^9 + 7 Sample Input 3Sample Output 3#include#inclu

2018-01-24 10:33:07 306

原创 只包含因子2 3 5的数

K的因子中只包含2 3 5。满足条件的前10个数是:2,3,4,5,6,8,9,10,12,15。 所有这样的K组成了一个序列S,现在给出一个数n,求S中 >= 给定数的最小的数。 例如:n = 13,S中 >= 13的最小的数是15,所以输出15。 Input 第1行:一个数T,表示后面用作输入测试的数的数量。(1 第2 - T + 1行:每行1个数N(1 Output

2018-01-24 10:19:30 343

原创 子段求和

给出一个长度为N的数组,进行Q次查询,查询从第i个元素开始长度为l的子段所有元素之和。例如,1 3 7 9 -1,查询第2个元素开始长度为3的子段和,1 {3 7 9} -1。3 + 7 + 9 = 19,输出19。 Input 第1行:一个数N,N为数组的长度(2 第2 至 N + 1行:数组的N个元素。(-10^9 i第N + 2行:1个数Q,Q为查询的数量。第

2018-01-24 09:36:30 247

原创 N的阶乘 (大数据)

输入N求N的阶乘的准确值。Input 输入N(1 Output 输出N的阶乘 Sample Input 5Sample Output 120代码:import java.math.BigInteger;import java.util.Scanner;public class Main { public static void main(String[] a

2018-01-24 09:26:18 519

原创 Burning Midnight Oil

One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists ofn lines of code. Vasya is already exhausted, so he works like that: first he writes

2018-01-23 21:39:47 224

原创 Another Problem on Strings

A string is binary, if it consists only of characters "0" and "1".String v is a substring of string w if it has a non-zero length and can be read starting from some position in stringw. For exam

2018-01-23 21:36:40 261

原创 3个数和为0

给出一个长度为N的无序数组,数组中的元素为整数,有正有负包括0,并互不相等。从中找出所有和 = 0的3个数的组合。如果没有这样的组合,输出No Solution。如果有多个,按照3个数中最小的数从小到大排序,如果最小的数相等则按照第二小的数排序。Input 第1行,1个数N,N为数组的长度(0 第2 - N + 1行:Ai(-10^9 iOutput 如果没有符合条件的组合,输

2018-01-23 18:17:22 449

原创 最长回文子串

回文串是指aba、abba、cccbccc、aaaa这种左右对称的字符串。输入一个字符串Str,输出Str里最长回文子串的长度。Input 输入Str(Str的长度 Output 输出最长回文子串的长度L。 Sample Input daabaacSample Output 5代码:dp[j][i]   j到i是回文字符串#include#include#i

2018-01-23 17:23:59 215

原创 数字1的数量

给定一个十进制正整数N,写下从1开始,到N的所有正数,计算出其中出现所有1的个数。例如:n = 12,包含了5个1。1,10,12共包含3个1,11包含2个1,总共5个1。 Input 输入N(1 Output 输出包含1的个数 Sample Input 12Sample Output 5大牛:点击打开链接代码:#include#includeusing nam

2018-01-23 16:34:43 218

空空如也

空空如也

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

TA关注的人

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