自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 poj1769(Minimizing maximizer)dp+线段树

DescriptionThe company Chris Ltd. is preparing a new sorting hardware called Maximizer. Maximizer has n inputs numbered from 1 to n. Each input represents one integer. Maximizer has one output wh...

2015-08-22 16:16:41 355

原创 poj3233(Matrix Power Series)快速幂

DescriptionGiven a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak.InputThe input contains exactly one test case. The first line of input con

2015-08-22 13:12:31 546 1

原创 poj2395(Out of Hay)最小生成树

DescriptionThe cows have run out of hay, a horrible event that must be remedied immediately. Bessie intends to visit the other farms to survey their hay situation. There are N (2 <= N <= 2,000)

2015-08-21 22:47:33 197 1

原创 poj2377(Bad Cowtractors)最大生成树

DescriptionBessie has been hired to build a cheap internet network among Farmer John's N (2 <= N <= 1,000) barns that are conveniently numbered 1..N. FJ has already done some surveying, and foun

2015-08-21 22:34:57 211 1

原创 poj1258(Agri-Net)最小生成树

DescriptionFarmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course. Farmer John

2015-08-21 22:18:22 224 1

原创 poj3641(Pseudoprime numbers)素性检测+快速幂

DescriptionFermat's theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and divide by p, the remainder is a. Some (but

2015-08-21 18:27:25 249 1

原创 poj3292(Semi-prime H-numbers)筛法

DescriptionThis problem is based on an exercise of David Hilbert, who pedagogically suggested that one study the theory of 4n+1 numbers. Here, we do only a bit of that.An H-number is a positiv

2015-08-21 17:46:24 276 1

原创 poj3421(X-factor Chains)质因数分解

题意:给定一个正整数 X,求满足1 1 2 m-1 题解:第一个想到的是深搜,枚举X因子,然后对除以因子后的数DFS,想想也会超时。。。然后往数学方面想,参考了大牛的博客后才恍然大悟。首先对X分解质因数,设X = a1^q1 * a2^q2 * ... * an^qn,那么最长的数链肯定是每次从n个质因子中取一个数,然后累乘到前一个数上面,所以最大的m就是q1+q2+...+q

2015-08-21 16:11:05 359 1

原创 poj3126(Prime Path)广搜+素数判定

DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices. —

2015-08-21 14:07:53 383 1

原创 poj3268(Silver Cow Party)最短路

DescriptionOne cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirect

2015-08-21 11:42:30 324

原创 poj3734(Blocks)快速幂+组合数学

题意:n个方块排成一列,每块可以涂成红蓝绿黄四种颜色,问红色方块和绿色方块个数同时为偶数的方案有多少种?题解:设ai, bi, ci分别表示到第i块为止红绿都是偶数、红绿有一个是偶数、红绿都是奇数方案数,那么ai+1 = 2ai + bibi+1 = 2ai + 2bi + 2cici+1 = bi + 2ci写成矩阵形式后用快速幂即可求解

2015-08-19 17:51:02 310

原创 poj2686(Traveling by Stagecoach)状态压缩dp

DescriptionOnce upon a time, there was a traveler. He plans to travel using stagecoaches (horse wagons). His starting point and destination are fixed, but he cannot determine his route. Your

2015-08-19 16:15:16 283

原创 poj2104(K-th Number)分桶法(平方分割)+线段树

DescriptionYou are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be ab

2015-08-19 13:15:06 271

原创 poj3259(Wormholes)最短路

DescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination

2015-08-18 19:01:44 278

原创 poj2139(Six Degrees of Cowvin Bacon)最短路

DescriptionThe cows have been making movies lately, so they are ready to play a variant of the famous game "Six Degrees of Kevin Bacon". The game works like this: each cow is considered to b

2015-08-18 18:08:13 229

原创 poj1703(Find them, Catch them)并查集

DescriptionThe police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to

2015-08-18 17:16:37 255

原创 poj2236(Wireless Network)并查集

DescriptionAn earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all c

2015-08-18 16:29:23 243

原创 poj2010(Moo University - Financial Aid)优先队列

DescriptionBessie noted that although humans have many universities they can attend, cows have none. To remedy this problem, she and her fellow cows formed a new university called The University

2015-08-18 15:08:24 293

原创 poj3614(Sunscreen)优先队列+贪心

DescriptionTo avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her hide with sunscreen when they're at the beach. Cow ihas a minimum and maximum SPF rating (1 ≤ 

2015-08-17 22:03:12 307

原创 poj3262(Protecting the Flowers)贪心

DescriptionFarmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When he returned, he found to his horror that the cluster of cows was in his garden eat

2015-08-17 15:44:45 507

原创 poj1862(Stripies)贪心

DescriptionOur chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian - polosatiki, but the scientists had to invent an Engl

2015-08-17 15:11:03 472

原创 poj3468(A Simple Problem with Integers)线段树+树状数组

DescriptionYou 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 i

2015-08-17 14:17:36 289

原创 poj2299(Ultra-QuickSort)树状数组+离散化

题目就是让你求逆序数,用树状数组很简单,不过数据太大,要先进行离散化,将数据范围压缩到1~n以内。还有poj竟然不支持c++11,害得我lambda表达式编译错误。#include #include #include #include #include #include #include #include #include #include #include #i

2015-08-17 11:39:59 292

原创 poj2991(Crane)线段树+计算几何

DescriptionACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of various lengths, connected by flexible joints. The end of the i-th segment is joined to the beginning

2015-08-16 21:57:57 321

原创 超大背包问题(折半枚举, 双向搜索)

有重量和价值分别为wi, vi (1 这是典型的01背包问题,不过dp求解复杂度为O(nW),这里W太大了,因此无法求解。挑选物品方法共有2^n种,也无法直接枚举。但是拆成两半再枚举的话还是可行的,每部分最多只有20个。假设第一部分某个选取方法对应的重量和价值为w1, v1,那么只要在第二部分中寻找w2+w1#include #include #include #in

2015-08-16 12:14:32 603

原创 poj3276(Face The Right Way)反转(开关问题)

DescriptionFarmer John has arranged his N (1 ≤ N ≤ 5,000) cows in a row and many of them are facing forward, like good cows. Some of them are facing backward, though, and he needs them all to fa

2015-08-15 17:36:34 300

原创 poj3320(Jessica's Reading Problem)尺取法

DescriptionJessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to mast

2015-08-15 16:55:18 210

原创 poj3061(Subsequence)尺取法

DescriptionA sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal

2015-08-15 16:40:05 224

原创 hdu5289(Assignment)

DescriptionTom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special task to so

2015-08-15 14:14:58 247

原创 hdu5288(OO’s Sequence)

DescriptionOO has got a array A of size n ,defined a function f(l,r) represent the number of i (li) satisfy a imod a j=0,now OO want to know() InputThere are multiple test

2015-08-15 11:46:52 291

原创 poj2392(Space Elevator)

DescriptionThe cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <= 400) different types of blocks with which

2015-08-14 21:38:52 224

原创 poj3666(Making the Grade)

DescriptionA straight dirt road connects two fields on FJ's farm, but it changes elevation more than FJ would like. His cows do not mind climbing up or down a single slope, but they are not fond

2015-08-14 20:52:34 364

原创 poj3181(Dollar Dayz)

DescriptionFarmer John goes to Dollar Days at The Cow Store and discovers an unlimited number of tools on sale. During his first visit, the tools are selling variously for $1, $2, and $3. Farmer

2015-08-14 16:00:34 269

原创 poj3046(Ant Counting)

DescriptionBessie was poking around the ant hill one day watching the ants march to and fro while gathering food. She realized that many of the ants were siblings, indistinguishable from one ano

2015-08-14 13:40:30 239

原创 poj1065(Wooden Sticks)

DescriptionThere is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs s

2015-08-14 11:01:18 316

原创 poj1631(Bridging signals)

Description'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 conn

2015-08-14 10:39:21 291

原创 poj1742(Coins)

DescriptionPeople in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar.One day Tony opened his money-box and found there were some coins.He decided to buy a very nice

2015-08-14 10:04:23 305

原创 poj3280(Cheapest Palindrome)

DescriptionKeeping track of all the cows can be a tricky task so Farmer John has installed a system to automate it. He has installed on each cow an electronic ID tag that the system will read as

2015-08-14 09:41:14 447

原创 poj3616(Milking Time)

DescriptionBessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she decides to schedule her next N (1 ≤ N ≤ 1,000,000) hours (conveniently labeled 0.

2015-08-13 18:35:27 244

原创 poj2385(Apple Catching)

DescriptionIt is a little known fact that cows love apples. Farmer John has two apple trees (which are conveniently numbered 1 and 2) in his field, each full of apples. Bessie cannot reach the a

2015-08-13 18:20:30 232

空空如也

空空如也

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

TA关注的人

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