自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 面积最大的矩形

1102 面积最大的矩形基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注有一个正整数的数组,化为直方图,求此直方图包含的最大矩形面积。例如 2,1,5,6,2,3,对应的直方图如下:面积最大的矩形为5,6组成的宽度为2的矩形,面积为10。Input第1行

2017-09-24 23:32:28 588

原创 Frequent Subsets Problem

题目来源2017 ACM-ICPC 亚洲区(南宁赛区)网络赛题意:n代表全集由{1,2,3,4,5,6...n-1,n}组成,再输入m个子集(S1,S2,S3...Sm),要求找出一些子集Ui,满足Ui是Sj的子集且这样的Sj个数>=w*m;eg.  n=5 w= 0.5       S1={1,5},S2={1.2,5},S3={1,4,5};       U1={1

2017-09-24 19:05:00 1782

原创 斐波那契数列模板

#includetypedef long long ll;using namespace std;const int mod = 998244353;struct mat { ll a[4]; void init() { a[0] = a[3] = 1; a[1] = a[2] = 0; } mat mul(const mat

2017-09-10 17:53:53 480

原创 fread

#define FI(n) FastIO::read(n)namespace FastIO { const int SIZE = 1 << 16; char buf[SIZE], obuf[SIZE], str[60]; int bi = SIZE, bn = SIZE, opt; int read(char *s) { while (bn) { for (; bi < bn

2017-08-25 11:16:54 307

原创 hdu 6181

题解:求次短路,先spfa跑一遍最短路,再依次删去最短路中的边找次短路,同时更新最短路顶点里最短的邻边,两种情况中取最小值。#include#include#include#include#includeusing namespace std;typedef long long ll;const ll inf=1e15+10;const int maxn=1e5+10;str

2017-08-25 11:14:59 383

原创 hdu 6156

数位dp#include#includeusing namespace std;typedef long long ll;int t,d[40],cur[40];ll L,R,l,r,dp[40][40][40][2];ll dfs(int k,int l,int r,bool flag,bool limit){ if(l==-1) return flag?k:1;

2017-08-24 15:47:03 298

原创 Found

FoundTime Limit: 10000ms, Special Time Limit:25000ms, Memory Limit:260144KBTotal submit users: 2, Accepted users: 2Problem 13881 : No special judgementProblem description

2017-08-23 15:16:11 746

原创 hdu 6170

题解:dp[i][j]表示b[1~i]匹配a[1~j]能否成功,注意a*开头的情况。#include#include#include using namespace std;const int maxn=2510;int t;bool dp[maxn][maxn];char a[maxn],b[maxn];int main(){ scanf("%d",&t); while(

2017-08-23 14:48:21 489 1

原创 hdu 6165

题解:先找出所有的强连通分量,再判断各分量能否满足要求(方法:不断地除去入度为0的分量,若出现两个入度为0的分量则不合法)#include#include#include#include#include#includeusing namespace std;const int maxn=1005;int t,n,m,dfn[maxn],f[maxn],low[maxn],mp[

2017-08-22 22:42:09 425

原创 Bundles of Joy

Problem description Bob’s Bakery is celebrating its grand opening! To commemorate this exciting occasion, they are offering a “Bundles of Joy” sale to encourage people to sample their full ran

2017-08-15 11:26:31 589

原创 Blood groups

Problem descriptionThere are four possible blood groups for humans: AB, A, B and O, meaning that the red blood cells have antigens of types, respectively, A and B, only A, only B, and no antigen

2017-08-11 21:00:23 378

原创 DNA Sequencing

Problem descriptionFinally, Plankton’s attempts to steal the Krabby Patty formula succeeded and it eventually put the Krusty Krab out of business. So, SpongeBob and his co-workers decided to swi

2017-08-11 11:56:51 598

原创 Cake cut

Problem descriptionCarol and Carla are roommates. Yesterday they threw a big party and today they have a partially eaten cake that they want to divide. Since people were careless when cutting th

2017-08-08 10:46:30 372

原创 1503 猪和回文

一只猪走进了一个森林。很凑巧的是,这个森林的形状是长方形的,有n行,m列组成。我们把这个长方形的行从上到下标记为1到n,列从左到右标记为1到m。处于第r行第c列的格子用(r,c)表示。刚开始的时候猪站在(1,1),他的目标是走到(n,m)。由于猪回家心切,他在(r,c)的时候,只会往(r+1,c)或(r,c+1)走。他不能走出这个森林。这只猪所在的森林是一个非同寻常的森林。有一些格

2017-08-07 16:57:19 571

原创 hdu6073 Matching In Multiplication

题解:首先如果一个点的度数为1,那么它的匹配方案是固定的,继而我们可以去掉这一对点。通过拓扑我们可以不断去掉所有度数为1的点。那么剩下的图中左右各有m个点,每个点度数都不小于2,且左边每个点度数都是2,而右侧总度数是2m,因此右侧只能是每个点度数都是2。这说明这个图每个连通块是个环,在环上间隔着取即可,一共两种方案。时间复杂度O(n)。#include#include#includ

2017-08-05 22:09:08 291

原创 hdoj 6071 Lazy Running

题解:任取节点2较小邻边的两倍作为mod,若可以通过距离x再次到达节点2,则可以通过x+mod,x+2*mod,x+3*mod...再次到达节点2.所以利用同余,spfa()跑最短路求d[i][j](i代表从2节点到i节点,j代表从2节点到i节点的距离%mod==j,d[i][j]代表2节点到i节点距离%mod==j的最短距离)当再次回到2节点时,更新ans,最短距离小于k时,ans=mi

2017-08-05 09:25:10 280

原创 hdu6070 Dirt Ratio

二分答案mid,检验是否存在一个区间满足size(l,r)/(r-l+1) ​≤mid,也就是size(l,r)+mid*l≤mid*(r+1)。#include#include#include#define lson l,mid,rt<<1#define rson mid+1,r,rt<<1|1using namespace std;const int maxn=6e4+10;

2017-08-04 16:56:04 249

原创 hdu6069 Counting Divisors

根据约数个数定理:n=p1^a1×p2^a2×p3^a3*…*pk^ak,n的约数的个数就是(a1+1)(a2+1)(a3+1)…(ak+1).若i=p1^a1×p2^a2×p3^a3*…*pk^ak,则i^K=p1^(a1*K)×p2^(a2*K)×p3^(a3*K)*…*pk^(ak*K),i^K的约数的个数就是(a1*K+1)(a2*K+1)(a3*K+1)…(ak*K+1)题目重点

2017-08-03 19:17:34 964

原创 hdu6060 RXD and dividing

题解:题目给出是一棵树,说明每条边都会用到,而每条边最多能用的次数为min(以该边连接的子节点为根的子树大小,k)#include#include#include#include#includeusing namespace std;typedef long long ll;const int maxn=1e6+10;struct edge{ int v,w;};i

2017-08-02 17:17:09 320

原创 hdu6058 Kanade's sum

题解:找出x左右两边大于x的k个数,左边记为cntl右边记为cntr,当cntl+cntr==k时,开始统计有多少个区间以x为第k大值。重点是从小到大找x,x的情况全部考虑完后,把x从链表里删掉。复杂度为O(n*k)#include#includeusing namespace std;typedef long long ll;const int maxn=1e6;int t

2017-08-02 12:45:49 355

原创 Dwarves

Problem descriptionOnce upon a time, there arose a huge discussion among the dwarves in Dwarfland. The government wanted to introduce an identity card for all inhabitants.Most dwarves accept t

2017-08-01 10:50:44 618

原创 Knapsack in a Globalized World

Problem descriptionGlobalization stops at nothing, not even at the good old honest profession of a burglar. Nowadays it is not enough to break in somewhere, take everything you can carry and dar

2017-08-01 10:11:48 547

原创 hdu6053TrickGCD(莫比乌斯反演)

参考:http://blog.csdn.net/u013632138/article/details/52250567          http://blog.csdn.net/xlzhang223/article/details/76218088#include#include#include#includeusing namespace std;typedef long l

2017-07-28 15:31:19 368

原创 1401 有趣的旅行

有N个城市,每个城市编号时从0到(N - 1),它们靠(N - 1)条双向道路相连。任意两个不同地城市之间都有一条唯一的路径相连。每个城市还有一个吸引力值,吸引力值越大的城市代表它越有趣,就越能吸引人。你要决定一次旅行,满足如下条件:(1) 计划中最多去K个城市(2) 必须可以从计划中的某个城市出发只经过计划中的城市达到计划中其他的城市——中途不能经过任何计划外的城市(3) 选入计划的

2017-07-26 11:22:27 587

原创 1967 路径定向

给出一个有向图,要求给每条边重定向,使得定向后出度等于入度的点最多,输出答案和任意一种方案Input第一行两个正整数N,M,表示1-N号点与M条边接下来M行,每行两个正整数Xi,Yi,表示存在一条有向边从Xi指向YiN≤10^5,   M≤3*10^5,   Xi,Yi≤NOutput第一行一个整数Ans,表示定向后出度等于入度的最大点数第二行一个长度

2017-07-25 11:39:10 424

原创 1967: Election

DescriptionAfter all the fundraising, campaigning and debating, the election day has finally arrived. Only two candidates remain on the ballot and you work as an aide to one of them.Reports from t

2017-07-24 11:12:59 296

原创 水群

总所周知,水群是一件很浪费时间的事,但是其实在水群这件事中,也可以找到一些有意思的东西。比如现在,bx2k就在研究怎样水表情的问题。首先,bx2k在对话框中输入了一个表情,接下来,他可以进行三种操作。第一种,是全选复制,把所有表情全选然后复制到剪贴板中。第二种,是粘贴,把剪贴板中的表情粘贴到对话框中。第三种,是退格,把对话框中的最后一个表情删去。假设

2017-07-24 10:15:49 2320

原创 1444 破坏道路

1444 破坏道路题目来源: CodeForces基准时间限制:1.5 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 收藏 关注在某一个国家,那儿有n个城市,他们通过m条双向道路相连。城市从1到n编号。如果城市a和b通过一条道路直接相连,那么他们之间的距离就是一个小时。这个国家的道路网络可以允许你从任意一个

2017-07-23 11:45:10 549 1

原创 Buy Sticks

Problem DescriptionImyourgod need 3 kinds of sticks which have different sizes: 20cm, 28cm and 32cm. However the shop only sell 75-centimeter-long sticks. So he have to cut off the long stick. How m

2017-07-22 11:41:47 321

原创 K - Co-prime HDU - 4135

Given a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N. Two integers are said to be co-prime or relatively prime if they have no co

2017-07-21 17:33:45 309

原创 M - How many integers can you find HDU - 1796

Now you get a number N, and a M-integers set, you should find out how many integers which are small than N, that they can divided exactly by any integers in the set. For example, N=12, and M-integer s

2017-07-21 17:31:34 284

原创 I - Hello Kiki HDU - 3579

One day I was shopping in the supermarket. There was a cashier counting coins seriously when a little kid running and singing "门前大桥下游过一群鸭,快来快来 数一数,二四六七八". And then the cashier put the counted coins ba

2017-07-21 17:20:13 395

原创 J - 2016 CSU - 1803

给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量:1. 1≤a≤n,1≤b≤m;2. a×b 是 2016 的倍数。Input输入包含不超过 30 组数据。每组数据包含两个整数 n,m (1≤n,m≤10 9).Output对于每组数据,输出一个整数表示满足条件的数量。

2017-07-21 17:03:12 378

原创 F - Pagodas HDU - 5512

nn pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 11 to nn. However, only two of them (labelled aa and bb, where 1≤a≠b≤n1≤a≠b≤n)

2017-07-21 16:58:29 234

原创 E - RealPhobia HDU - 4180

Bert is a programmer with a real fear of floating point arithmetic. Bert has quite successfully used rational numbers to write his programs but he does not like it when the denominator grows large. Yo

2017-07-21 16:50:39 495

原创 G - Domino Effect POJ - 1135

Did you know that you can use domino bones for other things besides playing Dominoes? Take a number of dominoes and build a row by standing them on end with only a small distance in between. If you do

2017-07-13 10:05:34 339

原创 F - Level up HDU - 3954

Level up is the task of all online games. It's very boooooooooring. There is only level up in those games, except level up. In a online game, there are N heroes numbered id from 1 to N, each begins

2017-07-12 22:58:21 373

原创 E - Cycling HDU - 2363

You want to cycle to a programming contest. The shortest route to the contest might be over the tops of some mountains and through some valleys. From past experience you know that you perform badly in

2017-07-12 13:17:13 349

原创 D - Theseus and labyrinth CodeForces - 676D

Theseus has just arrived to Crete to fight Minotaur. He found a labyrinth that has a form of a rectangular field of size n × m and consists of blocks of size 1 × 1.Each block of the labyrinth has a

2017-07-08 16:45:53 558

原创 H(1946): A Rational Sequence

DescriptionAn infinite full binary tree labeled by positive rational numbers is defined by:The label of the root is 1/1.The left child of label p/q is p/(p+q).The right child of label p/q is (p+

2017-07-03 14:53:30 534

空空如也

空空如也

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

TA关注的人

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