自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

SSimpLe_Y的博客

人一我百,人十我万,然而我做不到。

原创 hihocoder 1742 树的权重(51Nod-1405 树的距离之和)(树形DP)

描述给定一棵包含N个节点的树,节点编号1~N。  请你对于每一个节点,计算它到所有其他节点的距离之和。(每条边的长度为1)输入第一行包含一个整数N。  以下N-1行,每行包含两个整数a和b,代表ab之间有一条边。  对于30%的数据,1 ≤ N ≤ 1000  对于100%的数据,1 ≤ N ≤ ...

2018-05-13 15:21:14 510 0

原创 Codeforces Round #479 F. Consecutive Subsequence(DP)

You are given an integer array of length nn.You have to choose some subsequence of this array of maximum length such that this subsequence forms a in...

2018-05-09 11:23:23 302 0

原创 SPOJ DQUERY - D-query (莫队算法)

Given a sequence of n numbers a1, a2, ..., an and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you hav...

2018-04-11 22:07:00 436 0

原创 2460: [BeiJing2011]元素 (线性基)

Description  相传,在远古时期,位于西方大陆的 Magic Land 上,人们已经掌握了用魔法矿石炼制法杖的技术。那时人们就认识到,一个法杖的法力取决于使用的矿石。一般地,矿石越多则法力越强,但物极必反:有时,人们为了获取更强的法力而使用了很多矿石,却在炼制过程中发现魔法矿石全部消失了...

2018-04-11 20:48:10 434 0

原创 hihocoder 1723 : 子树统计 (线性基)

描述给定一棵N个节点的有根树,树上每个节点有一个非负整数权重Wi。定义节点集合S={i1, i2, ……, ir}的总权重为:(⊕是异或运算)每次询问一棵子树内所有可能出现的总权重数量,即令E为所询问的子树内节点的集合,|T|即为可能出现的总权重数量。输入第一行包含两个整数N,Q,表示树的节点数目...

2018-04-10 20:52:40 508 0

原创 线性基(处理集合异或的强力工具)

看了好多篇关于线性基的博客,只是说明了怎么求线性基,但是大都没有说明为什么这样求线性基。定义:有一个集合 S  = {a1,a2...,an},T的满足下面条件的一个最小子集A = {a1,a2,....,ak}A的所有子集的异或和的值域与T的所有子集的异或和的值域相同,那么A就是T的线性基。预备...

2018-04-10 20:37:59 1088 0

原创 最小公倍数取模

题目:求一个最小的整数,能被1~n中的所有数整除。n的范围为 1 <= n <= 100000,答案对1e9+7取模。   思路:一上来有些人可能认为可以先求最小公倍数然后再取模,这样显然是不可以的,因为求最小公倍数中有除法,除法是不能直接取模的,就算用了逆元,也是...

2018-04-10 20:08:04 906 0

原创 查询区间内等于x的数的个数(分块)

问题:有一个有n个数的数组,q次查询,每次查询l, r ,x,查询区间[l,r]内等于x的数的个数思路:分块。就把这题当成是分块的入门题来讲解一下分块。分块其实就是一种比较优美的暴力(我觉得),一般的分块都是把长度为n的数组分成每一块为sqrt(n)个数的多个块。然后对于区间的操作就可以不再是一个...

2018-03-24 17:02:22 1663 1

原创 Codeforces Round #466 (Div. 2) E. Cashback (dp+树状数组+RMQ)

Since you are the best Wraith King, Nizhniy Magazin «Mir» at the centre of Vinnytsia is offering you a discount.You are given an array a of length n ...

2018-02-24 21:09:36 779 0

原创 Codeforces Round #464 (Div. 2) E. Maximize!

You are given a multiset S consisting of positive integers (initially empty). There are two kind of queries:Add a positive integer to S, the newly ad...

2018-02-17 22:32:43 879 0

原创 Codeforces Round #464 (Div. 2) D. Love Rescue

Valya and Tolya are an ideal pair, but they quarrel sometimes. Recently, Valya took offense at her boyfriend because he came to her in t-shirt with l...

2018-02-17 22:20:12 1035 0

原创 Codeforces Round #464 (Div. 2) C. Convenient For Everybody

In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For...

2018-02-17 22:12:51 887 0

原创 分类占坑

图论:最短路网络流强连通生成树匹配数据结构:线段树树状数组RMQLCA字符串后缀数组字典树数学相关莫比乌斯反演计算几何数论矩阵FFT其他:二分搜索DP...

2018-02-12 13:11:11 147 0

原创 BZOJ 2442[Usaco2011 Open] 修剪草坪 (dp+单调队列)

Description 在一年前赢得了小镇的最佳草坪比赛后,FJ变得很懒,再也没有修剪过草坪。现在, 新一轮的最佳草坪比赛又开始了,FJ希望能够再次夺冠。然而,FJ的草坪非常脏乱,因此,FJ只能够让他的奶牛来完成这项工作。FJ有N (1 <= N <= 100,000...

2018-02-12 12:10:48 747 0

原创 Codecraft-18 and Codeforces Round #458 D. Bash and a Tough Math Puzzle(线段树)

Bash likes playing with arrays. He has an array a1, a2, ... an of n integers. He likes to guess the greatest common divisor (gcd) of different segm...

2018-01-21 13:22:11 925 0

原创 Codecraft-18 and Codeforces Round#458 C. Travelling Salesman and Special Numbers(数位DP)

The Travelling Salesman spends a lot of time travelling so he tends to get bored. To pass time, he likes to perform operations on numbers. One such o...

2018-01-21 13:10:30 740 0

原创 SGU 144. Meeting(概率)

Two of the three members of the winning team of one of the ACM regional contests are going to meet in order to train for the upcoming World Finals. T...

2017-10-14 19:11:56 673 0

原创 SGU 143. Long Live the Queen(树形DP)

The Queen of Byteland is very loved by her people. In order to show her their love, the Bytelanders have decided to conquer a new country which will ...

2017-10-14 18:22:04 687 0

原创 SGU 142. Keyword(暴力枚举)

Kevin has invented a new algorithm to crypt and decrypt messages, which he thinks is unbeatable. The algorithm uses a very large key-string, out of w...

2017-10-14 16:55:13 446 0

原创 SGU 134. Centroid(树的重心)

You are given an undirected connected graph, with N vertices and N-1 edges (a tree). You must find the centroid(s) of the tree.  In order to define ...

2017-10-13 16:50:01 738 0

原创 SGU 125. Shtirlits(dfs)

There is a checkered field of size N x N cells (1 Ј N Ј 3). Each cell designates the territory of a state (i.e. N2 states). Each state has an army. ...

2017-10-10 20:06:03 651 0

原创 SGU 124. Broken line(射线法判断一个点是否在一个多边形内)

There is a closed broken line on a plane with sides parallel to coordinate axes, without self-crossings and self-contacts. The broken line consists o...

2017-10-09 21:03:55 644 0

原创 SGU 116. Index of super-prime(完全背包+输出路径)

Let P1, P2, … ,PN, … be a sequence of prime numbers. Super-prime number is such a prime number that its current number in prime numbers sequence is a...

2017-09-27 14:38:22 675 0

原创 SGU 115. Calendar (基姆拉尔森公式)

irst year of new millenium is gone away. In commemoration of it write a program that finds the name of the day of the week for any date in 2001. In...

2017-09-27 12:37:24 679 0

原创 Codeforces Round #436 (Div. 2) E. Fire(01背包+输出路径)

Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take t...

2017-09-26 18:12:08 938 0

原创 Manthan, Codefest 17 C. Helga Hufflepuff's Cup(树形DP)

Harry, Ron and Hermione have figured out that Helga Hufflepuff's cup is a horcrux. Through her encounter with Bellatrix Lestrange, Hermione came...

2017-09-25 08:43:29 879 0

原创 Manthan, Codefest 17 E. Salazar Slytherin's Locket(数位DP)

Harry came to know from Dumbledore that Salazar Slytherin's locket is a horcrux. This locket was present earlier at 12 Grimmauld Place, the home...

2017-09-25 07:34:25 670 0

原创 2017北京网络赛 && hihocoder 1582 Territorial Dispute(凸包)

In 2333, the C++ Empire and the Java Republic become the most powerful country in the world. They compete with each other in the colonizing the Mars....

2017-09-24 19:46:28 588 0

原创 大数模板 (kuangbin模板的修订版)

以前直接用kuangbin的模板,发现一直过不了题,今天又做了一题,发现原来是减法函数里有一个地方写错了,改正之后就可以了(不保证其他的没有问题)。 #include #include #include #include #define LL long long using names...

2017-09-21 15:17:30 1125 3

原创 Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor

Mahmoud and Ehab are on the third stage of their adventures now. As you know, Dr. Evil likes sets. This time he won't show them any set from his...

2017-09-20 08:58:35 976 5

原创 SGU 103. Traffic Lights (SPFA)

In the city of Dingilville the traffic is arranged in an unusual way. There are junctions and roads connecting the junctions. There is at most one r...

2017-09-18 13:57:25 819 0

原创 Codeforces Round #434 D. Polycarp's phone book (字典树)

There are n phone numbers in Polycarp's contacts on his phone. Each number is a 9-digit integer, starting with a digit different from 0. All t...

2017-09-18 08:20:19 806 0

原创 Codeforces Round #433 C. Planning(贪心)

Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of th...

2017-09-07 08:01:11 1303 0

原创 Codeforces Round #433 D. Jury Meeting

Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the ...

2017-09-07 00:15:51 641 0

原创 2017 广西邀请赛&& hdu 6191 Query on A Tree(字典树启发式合并)

Problem Description Monkey A lives on a tree, he always plays on this tree. One day, monkey A learned about one of the bit-operations, xor. He was ...

2017-09-01 12:03:49 681 0

原创 bzoj 2733: [HNOI2012]永无乡(线段树启发式合并)

Description 永无乡包含 n 座岛,编号从 1 到 n,每座岛都有自己的独一无二的重要度,按照重要度可 以将这 n 座岛排名,名次用 1 到 n 来表示。某些岛之间由巨大的桥连接,通过桥可以从一个岛 到达另一个岛。如果从岛 a 出发经过若干座(含 0 座)桥可以到达岛 b,则称岛 ...

2017-08-31 21:35:34 653 0

原创 bzoj 2301 [HAOI2011]Problem b (莫比乌斯反演)

Description 对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数。 Input 第一行一个整数n,接下来n行每行五个整数,分别表示a、b、c、d、k   Ou...

2017-08-16 10:21:10 725 0

原创 spoj 7001 VLATTICE - Visible Lattice Points(莫比乌斯反演)

Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at (N,N,N). How many lattice points are visible from corner at (0,0,0) ? A...

2017-08-15 10:48:22 668 0

原创 bzoj 2005 能量采集(莫比乌斯反演)

Description 栋栋有一块长方形的地,他在地上种了一种能量植物,这种植物可以采集太阳光的能量。在这些植物采集能量后, 栋栋再使用一个能量汇集机器把这些植物采集到的能量汇集到一起。 栋栋的植物种得非常整齐,一共有n列,每列 有m棵,植物的横竖间距都一样,因此对于每一棵植物,栋栋可以用一个坐...

2017-08-15 10:38:18 672 0

原创 bzoj 2818 Gcd(莫比乌斯反演)

Description 给定整数N,求1 数对(x,y)有多少对. Input 一个整数N Output 如题 Sample Input 4 Sample Output 4 HINT hint 对于样例(2,2),(...

2017-08-15 10:29:51 694 0

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