- 博客(81)
- 收藏
- 关注
原创 Stars (HDU 1541)
Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and ...
2018-07-31 19:59:12 207
原创 Color the ball(HDU 1556)
N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数...
2018-07-31 14:42:47 179
转载 判断两三角形是否相交(模板)
#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespace std;const double eps=1e-8;const double pi=acos(-1.0);int sgn(double x){ if (fa...
2018-07-31 11:26:39 1846
原创 A Simple Problem with Integers(POJ 3468)
You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the ...
2018-07-31 11:19:13 116
原创 Lazy-Tag(线段数思想)
lazy-tag思想,记录每一个线段树节点的变化值,当这部分线段的一致性被破坏我们就将这个变化值传递给子区间,大大增加了线段树的效率。 在此通俗的解释我理解的Lazy意思: 现在需要对[a,b]区间值进行加c操作,那么就从根节点[1,n]开始调用update函数进行更新操作;如果刚好执行到一个rt节点,而且tree[rt].l == a && tree[rt].r == b,这...
2018-07-31 11:09:55 533
原创 Just a Hook(HDU 1698)
In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. Now Pud...
2018-07-31 11:02:39 215
原创 I Hate It(HDU 1754)
很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<M<5...
2018-07-31 11:01:25 166
原创 敌兵布阵 (HDU 1166)
C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究竟演习什么战术,所...
2018-07-31 10:59:39 240
原创 Polycarp and Div 3(CodeForces 1005D)
Polycarp likes numbers that are divisible by 3.He has a huge number ss. Polycarp wants to cut from it the maximum number of numbers that are divisible by 33. To do this, he makes an arbitrary number...
2018-07-31 08:27:50 169
原创 Summarize to the Power of Two(CodeForces - 1005C )
A sequence a1,a2,…,ana1,a2,…,an is called good if, for each element aiai, there exists an element ajaj (i≠ji≠j) such that ai+ajai+aj is a power of two (that is, 2d2d for some non-negative integer dd)....
2018-07-30 21:48:13 266
转载 线段数模板
单点更新:#include<cstdio>#include<iostream>#include<string>#include<cmath>using namespace std;const int MAXNODE = 1 << 19;const int MAX = 2e5 + 10;typedef struct No...
2018-07-30 16:04:26 271
原创 Flip the Bits
You are given a positive integer n. Your task is to build a number m by flipping the minimum number of bits in the binary representation of nsuch that m is less than n (m < n) and it is as maximal ...
2018-07-30 08:45:50 432
转载 _builtin_popcount()计算二进制中多少个1
计算一个 32 位无符号整数有多少个位为1Counting out the bits 可以很容易的判断一个数是不是2的幂次:清除最低的1位(见上面)并且检查结果是不是0.尽管如此,有的时候需要直到有多少个被设置了,这就相对有点难度 了。 GCC有一个叫做__builtin_popcount的内建函数,它可以精确的计算1的个数。尽管如此,不同于__builtin_ctz,它并没...
2018-07-30 08:31:22 297
原创 Magic Sticks
You are given a n × m grid, your goal is to find a group of lines such that the following conditions are met:No two lines are touching. Each cell in the grid has one of its sides covered by at leas...
2018-07-29 15:05:16 543 2
原创 Friends and Cookies
Abood's birthday has come, and his n friends are aligned in a single line from 1 to n, waiting for their cookies, Abood has x cookies to give to his friends.Here is an example to understand how Aboo...
2018-07-29 14:27:04 354
转载 莫比乌斯函数之和(51nod 1244)
莫比乌斯函数,由德国数学家和天文学家莫比乌斯提出。梅滕斯(Mertens)首先使用μ(n)(miu(n))作为莫比乌斯函数的记号。具体定义如下:如果一个数包含平方因子,那么miu(n) = 0。例如:miu(4), miu(12), miu(18) = 0。如果一个数不包含平方因子,并且有k个不同的质因子,那么miu(n) = (-1)^k。例如:miu(2), miu(3), miu(3...
2018-07-28 11:19:34 596
原创 莫比乌斯函数 (51Nod - 1240)
莫比乌斯函数,由德国数学家和天文学家莫比乌斯提出。梅滕斯(Mertens)首先使用μ(n)(miu(n))作为莫比乌斯函数的记号。(据说,高斯(Gauss)比莫比乌斯早三十年就曾考虑过这个函数)。具体定义如下:如果一个数包含平方因子,那么miu(n) = 0。例如:miu(4), miu(12), miu(18) = 0。如果一个数不包含平方因子,并且有k个不同的质因子,那么miu(n...
2018-07-28 10:47:44 337
原创 Dice (III) (light oj 1248 概率dp)
Given a dice with n sides, you have to find the expected number of times you have to throw that dice to see all its faces at least once. Assume that the dice is fair, that means when you throw the dic...
2018-07-28 10:41:46 304
原创 Island of Survival ( LightOJ1265 概率dp)
You are in a reality show, and the show is way too real that they threw into an island. Only two kinds of animals are in the island, the tigers and the deer. Though unfortunate but the truth is that, ...
2018-07-28 10:37:42 488
原创 Throwing Balls into the Baskets (Light OJ 1317 概率dp)
You probably have played the game "Throwing Balls into the Basket". It is a simple game. You have to throw a ball into a basket from a certain distance. One day we (the AIUB ACMMER) were playing the g...
2018-07-28 10:32:43 193
原创 Discovering Gold (lightoj 1030 概率dp)
You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold.Initially you are in position 1. Now each turn you throw a perfect 6...
2018-07-28 10:29:33 156
原创 Rescue (ZOJ - 1649 )
Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.Angel's friends want to...
2018-07-28 08:49:16 240
原创 Coins and Queries(CodeForces 1003D)
Polycarp has nn coins, the value of the ii-th coin is aiai. It is guaranteed that all the values are integer powers of 22 (i.e. ai=2dai=2d for some non-negative integer number dd).Polycarp wants to ...
2018-07-27 16:35:06 287
转载 sscanf和sprintf()函数的详细说明
sprintf()使用说明在将各种类型的数据构造成字符串时,sprintf 的强大功能很少会让你失望。由于sprintf 跟printf 在用法上几乎一样,只是打印的目的地不同而已,前者打印到字符串中,后者则直接在命令行上输出。这也导致sprintf 比printf 有用得多。sprintf 是个变参函数,定义如下:int sprintf( char *buffer, const ch...
2018-07-27 09:31:54 319
转载 C++库常用函数一览
本文中提到的函数库有:<string> <cctype> <algorithm> <cmath> <cstdlib> <iomanip> <numeric>1. 标准C++库字符串类std::string的用法begin 得到指向字符串开头的Iteratorend 得到指向
2018-07-27 09:22:44 425
转载 C++中的STL中map用法详解
C++ map的基本操作和使用Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作!1、map简介map是一类关联式容器。它的特点是增加和删除节点对迭代器的影响很小,除了那个操作节点,对其他的节点都没有什么影响。对于迭代器来说,可以修改实值,而不能修改key。2、map的功能自动建立Key ...
2018-07-27 09:00:52 192
原创 Intense Heat(CodeForces 1003C)
The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But an...
2018-07-27 08:29:39 181
原创 Binary String Constructing(CodeForces 1003B)
You are given three integers aa, bb and xx. Your task is to construct a binary string ss of length n=a+bn=a+bsuch that there are exactly aa zeroes, exactly bb ones and exactly xx indices ii (where 1≤i...
2018-07-26 21:43:20 203
原创 Fruit (hdu 2152)
转眼到了收获的季节,由于有TT的专业指导,Lele获得了大丰收。特别是水果,Lele一共种了N种水果,有苹果,梨子,香蕉,西瓜……不但味道好吃,样子更是好看。 于是,很多人们慕名而来,找Lele买水果。 甚至连大名鼎鼎的HDU ACM总教头 lcy 也来了。lcy抛出一打百元大钞,"我要买由M个水果组成的水果拼盘,不过我有个小小的要求,对于每种水果,个数上我有限制,既不能少于某个特定值,也不能...
2018-07-26 11:36:29 230
原创 一卡通大冒险(hdu 2512 )
因为长期钻研算法, 无暇顾及个人问题,BUAA ACM/ICPC 训练小组的帅哥们大部分都是单身。某天,他们在机房商量一个绝妙的计划"一卡通大冒险"。这个计划是由wf最先提出来的,计划的内容是,把自己的联系方式写在校园一卡通的背面,然后故意将自己的卡"遗失"在某处(如水房,TD,食堂,主M。。。。)他们希望能有MM看到他们遗失卡,能主动跟他们联系,这样就有机会请MM吃饭了。他们决定将自己的一卡通夹...
2018-07-25 20:35:49 848
转载 高斯消元模板
kuangbin大牛的模板 #include<stdio.h> #include<algorithm> #include<iostream> #include<string.h> #include<math.h> using namespace std; const int MA...
2018-07-25 17:23:48 135
转载 母函数详解和史上最通用最高效的母函数模板
母函数,又称生成函数,是ACM竞赛中经常使用的一种解题算法,常用来解决组合方面的题目。本文讲解母函数,但不讲解该算法的基础理论。读者随便找一本组合数学教材便可找到相应的内容,或者直接在网上搜索一下。母函数通常解决类似如下的问题:给5张1元,4张2元,3张5元,要得到15元,有多少种组合?某些时候会规定至少使用3张1元、1张2元、0张5元。某些时候会规定有无数张1元、2元、5元。...
2018-07-25 14:34:39 276
原创 Max Sum (hdu 1003)
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14. InputThe...
2018-07-25 11:21:14 183
原创 Super Jumping! Jumping! Jumping! (hdu 1087)
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now. The game ...
2018-07-25 11:17:18 226
原创 FatMouse's Speed (hdu 1160)
FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence...
2018-07-25 11:10:21 239
转载 Java实现大数操作
先从最简单的来说:1.输出hello worldpackage BigInteger;public class Main { public static void main(String args[]) { System.out.println("Hello world"); }}关于上面的package BigInteger,提交代码时不需要粘贴。2.计算a+b...
2018-07-24 16:44:24 852
原创 Bridging signals (POJ 1631 HDU 1950)
'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports ...
2018-07-24 16:38:17 243
原创 最少拦截系统 (HDU 1257)
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹. 怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统...
2018-07-24 16:27:51 170
原创 Advanced Fruits(HDU1503)
Problem DescriptionThe company "21st Century Fruits" has specialized in creating new sorts of fruits by transferring genes from one fruit into the genome of another one. Most times this method doesn...
2018-07-24 16:20:12 201
原创 Common Subsequence(HDU 1159,最长公共子序列)
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another sequence Z = <z1, z2, ..., zk> is a subs...
2018-07-24 16:04:58 171
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人