自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 UVALive5964 LCM Extreme && UVA11426 GCD - Extreme (II) 欧拉函数筛法

UVALive5964 LCM Extreme 点击打开链接UVA11426 GCD - Extreme (II)  点击打开链接#include #include #include #include #include #include #include #include #include using namespace std;#define LL

2017-04-12 14:44:52 483

原创 POJ2398 Toy Storage 判断点和线的关系+二分+计数

Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them. They gave Reza a rectangular box to put his toys in. Unfortunately, Reza is rebellious an

2017-04-12 14:35:52 457

原创 CodeFroces723D Lakes in Berland BFS

The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean.Lakes are the maximal regions of

2017-04-07 23:45:22 341

原创 CodeForces723C Polycarp at the Radio 贪心

Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence a1, a2, ..., an, where ai is a band, which performs the i-th song. Polyc

2017-04-07 23:10:11 403

原创 bzoj1026 windy数 数位DP

windy定义了一种windy数。不含前导零且相邻两个数字之差至少为2的正整数被称为windy数。 windy想知道,在A和B之间,包括A和B,总共有多少个windy数?Input  包含两个整数,A B。Output  一个整数Sample Input【输入样例一】1 10【输入样例二】25 50Sample Output【输出样例一】

2017-03-31 10:19:37 458

原创 CodeForces782B The Meeting Place Cannot Be Changed 三分查找

The main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost building in north direction.At some points on the roa

2017-03-06 13:15:24 360

原创 CodeForces733D Kostya the Sculptor 贪心+二分

Kosta is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present

2016-11-01 13:43:47 498

原创 CodeForces712C Memory and De-Evolution 数学+贪心

Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral t

2016-09-15 13:12:02 413

原创 LightOJ1109 False Ordering 筛法求约数个数+结构体排序

We define b is a Divisor of a number a if a is divisible by b. So, the divisors of 12 are 1, 2, 3, 4, 6, 12. So, 12 has 6 divisors.Now you have to order all the integers from 1 to 1000. x will come

2016-09-06 22:04:26 326

原创 LightOJ1014 Ifter Party

DescriptionI have an Ifter party at the 5th day of Ramadan for the contestants. For this reason I have invited C contestants and arranged P piaju's (some kind of food, specially made for Ifter). Eac

2016-09-05 21:57:53 471

原创 LightOJ1067 Combinations Lucas定理裸题

DescriptionGiven n different objects, you want to take k of them. How many ways to can do it?For example, say there are 4 items; you want to take 2 of them. So, you can do it 6 ways.Take 1, 2T

2016-09-05 19:57:16 696

原创 LightOJ1045 Digits of Factorial 求n的阶乘在k进制下的位数

DescriptionFactorial of an integer is defined by the following functionf(0) = 1f(n) = f(n - 1) * n, if(n > 0)So, factorial of 5 is 120. But in different bases, the factorial may be different.

2016-09-05 12:35:05 533

原创 LightOJ1278 Sum of Consecutive Integers 素数筛法+数学分析

DescriptionGiven an integer N, you have to find the number of ways you can express N as sum of consecutive integers. You have to use at least two integers.For example, N = 15 has three solutions,

2016-09-04 23:19:02 496

原创 LightOJ1215 Finding LCM

LCM is an abbreviation used for Least Common Multiple in Mathematics. We say LCM (a, b, c) = L if and only if L is the least integer which is divisible by a, b and c.You will be given a, b and L.

2016-09-04 22:59:06 392

原创 LightOJ1007 Mathematically Hard 欧拉函数+前缀和

DescriptionMathematically some problems look hard. But with the help of the computer, some problems can be easily solvable.In this problem, you will be given two integers a and b. You have to fi

2016-09-04 22:29:39 530

原创 CodeForces711E ZS and The Birthday Paradox 费马小定理求逆元

ZS the Coder has recently found an interesting concept called the Birthday Paradox. It states that given a random set of 23 people, there is around 50% chance that some two of them share the same birt

2016-09-04 17:03:32 692

原创 CSU1803 2016 同余

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

2016-09-04 16:08:37 1393

原创 CodeForces704B Spider Man

Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so

2016-08-08 19:26:37 617

原创 Hdu5804 Price List

Problem DescriptionThere are n shops numbered with successive integers from 1 to n in Byteland. Every shop sells only one kind of goods, and the price of the i-th shop's goods is vi.Ev

2016-08-07 20:07:10 475 6

原创 Hdu5776 sum 抽屉原理+同余定理

Problem DescriptionGiven a sequence, you're asked whether there exists a consecutive subsequence whose sum is divisible by m. output YES, otherwise output NO InputThe first line of the input

2016-08-07 20:05:12 487 3

原创 CodeForces703B Mishka and trip 数学

Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some intere

2016-08-06 16:49:43 397

原创 NYOJ116 士兵杀敌(二) 线段数、单点更新

描述南将军手下有N个士兵,分别编号1到N,这些士兵的杀敌数都是已知的。小工是南将军手下的军师,南将军经常想知道第m号到第n号士兵的总杀敌数,请你帮助小工来回答南将军吧。南将军的某次询问之后士兵i可能又杀敌q人,之后南将军再询问的时候,需要考虑到新增的杀敌数。输入只有一组测试数据第一行是两个整数N,M,其中N表示士兵的个数(1随后的一行是N

2016-08-02 17:48:37 239

原创 NYOJ499 迷宫 DFS

描述一个由 n * m 个格子组成的迷宫,起点是(1, 1), 终点是(n, m),每次可以向上下左右四个方向任意走一步,并且有些格子是不能走动,求从起点到终点经过每个格子至多一次的走法数。输入第一行一个整数 T 表示有 T 组测试数据。(T 对于每组测试数据:第一行两个整数 n, m,表示迷宫有 n * m 个格子。(1 输出对于每组测试数据,输出一个整数 R

2016-08-02 17:09:49 309

原创 NYOJ739 笨蛋难题四

描述这些日子笨蛋一直研究股票,经过调研,终于发现xxx公司股票规律,更可喜的是 笨蛋推算出这家公司每天的股价,为了防止别人发现他的秘密。他决定对于这家公司的 股票最多买一次,现在笨蛋已经将股票价格列了出来。(这已经不是笨蛋的难题了,他已经解决 呵 呵)。只想难为难为你呀,从股票价格表上,你能算出笨蛋的每股股票最多能赚多少钱吗?                 输入第

2016-08-02 16:00:10 473

原创 NYOJ49 开心的小明 DFS/01背包

描述小明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间。更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过N 元钱就行”。今天一早小明就开始做预算,但是他想买的东西太多了,肯定会超过妈妈限定的N 元。于是,他把每件物品规定了一个重要度,分为5 等:用整数1~5 表示,第5 等最重要。他还从因特网上查到了每件物品的价格(都是整

2016-08-02 14:26:39 393

原创 HDU1232/NYOJ608 畅通工程 并查集

Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 100

2016-08-02 11:54:38 793

原创 NYOJ55 懒省事的小明

描述      小明很想吃果子,正好果园果子熟了。在果园里,小明已经将所有的果子打了下来,而且按果子的不同种类分成了不同的堆。小明决定把所有的果子合成一堆。 因为小明比较懒,为了省力气,小明开始想点子了:  每一次合并,小明可以把两堆果子合并到一起,消耗的体力等于两堆果子的重量之和。可以看出,所有的果子经过n-1次合并之后,就只剩下一堆了。小明在合并果子时总共消耗的体力等于每次合并所耗体力

2016-08-02 10:45:51 439

原创 CodeForces702B Powers of Two

You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i InputThe first line contains the single positive integer n (1 ≤ n ≤ 105) — the number of integers.The second

2016-07-30 21:05:41 411

原创 POJ1569 Myacm Triangles 判断点与三角形的关系

DescriptionThere has been considerable archeological work on the ancient Myacm culture. Many artifacts have been found in what have been called power fields: a fairly small area, less than 100

2016-07-28 11:06:50 432

原创 POJ2007 Scrambled Polygon 凸多边形顶点输出

DescriptionA closed polygon is a figure bounded by a finite number of line segments. The intersections of the bounding line segments are called the vertices of the polygon. When one starts at any

2016-07-27 20:14:45 301

原创 POJ1789 Truck History Prim+堆(优先队列)、Kruskal(并查集)

DescriptionAdvanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing ea

2016-07-26 20:06:13 438

原创 POJ2349 Arctic Network Prim+堆(优先队列)、Kruskal(并查集)

DescriptionThe Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the n

2016-07-26 18:28:00 406

原创 CodeForces429B Working out

DescriptionSummer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i]

2016-07-25 12:21:06 842

原创 POJ2606&1118 同直线最多点数

POJ1118 传送门POJ2606 传送门这两道题都是要求给定n个点中,处于一条直线上的点最点有多少个。我们可以枚举每一个点,求出其余点与其斜率,并排序,这样就能解决该问题了。列举过的点可以不必枚举,因为不可能出现漏算的情况。在枚举过程中,在枚举第 i 个点时,在其之前有一点与其之后一点,这三点均处于同一直线,那么,在枚举前一个点时,已经将该直线上的点进行了计

2016-07-24 23:52:31 275

原创 URAL1009 K-based Numbers

DescriptionLet’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

2016-07-24 23:19:44 298

原创 POJ2492 A Bug's Life 并查集

DescriptionBackground Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of t

2016-07-24 18:37:58 234

原创 POJ1182 食物链 并查集

Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个动物

2016-07-24 16:31:04 283

原创 Hdu5671 Matrix 矩阵、行列交换+行列加值

Problem DescriptionThere is a matrix M that has n rows and m columns (1≤n≤1000,1≤m≤1000).Then we perform q(1≤q≤100,000) operations:1 x y: Swap row x and row y (1≤x,y≤n);2 x y: Swap

2016-07-24 11:51:29 482

原创 Hdu1754 I Hate It 线段树、单点更新+区间最值

Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N 和 M ( 0

2016-07-24 10:49:54 268

原创 Poj2828 Buy Tickets 线段树、单点更新

DescriptionRailway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue…The Lunar New Year was approaching, but unluckily the Little Ca

2016-07-23 18:23:49 360

空空如也

空空如也

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

TA关注的人

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