自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Sky Code - POJ 3904 容斥原理

Sky CodeTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 1705 Accepted: 528DescriptionStancu likes space travels but he is a poor software developer an

2015-03-31 17:26:46 452

原创 跳蚤 - POJ 1091 容斥原理

跳蚤Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 8723 Accepted: 2601DescriptionZ城市居住着很多只跳蚤。在Z城市周六生活频道有一个娱乐节目。一只跳蚤将被请上一个高空钢丝的正中央。钢丝很长,可以看作是无限长。节目主持人会给

2015-03-31 17:22:41 1377

原创 Happy 2006 - POJ 2773 欧几里得

Happy 2006Time Limit: 3000MS Memory Limit: 65536KTotal Submissions: 10084 Accepted: 3460DescriptionTwo positive integers are said to be relatively prime to each

2015-03-31 10:41:47 510

原创 Cable TV Network- POJ 1966 连通量

Cable TV NetworkTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 4068 Accepted: 1903DescriptionThe interconnection of the relays in a cable TV network

2015-03-25 09:44:58 488

原创 How Many Fibs? - UVa 10183 大数加法

题意:在L-R的范围内有多少斐波那契数。思路:大数加法,然后挨个找即可。AC代码如下:import java.math.BigInteger;import java.util.Scanner;public class Main { public static void main(String [] args) { Scanner scan=new Scanner(Sy

2015-03-24 23:32:56 558

原创 Gift Exchanging - UVa 10417 概率dp

题意:给你你的n个小伙伴一人给你带了一种类型的礼物,告诉你各个礼物的数量,和每个小伙伴给哪种礼物的概率,问你选择哪种类型的礼物最有可能是第一个人给的,这个概率是多少。思路:设A为第一个小伙伴给某种礼物的概率,B为所有人给的礼物恰好是给定的数目的概率P(A|B)=P(AB)/P(B)。B的概率由dp递推得出。最后还得除以这个礼物的数目,再找到最大的这个概率。AC代码如下:#include

2015-03-24 22:54:22 595

原创 Burger - UVa 557 概率dp

BurgerWhen Mr. and Mrs. Clinton's twin sons Ben and Bill had their tenth birthday, the party was held at the McDonald's restaurant at South Broadway 202, New York. There were 20 kids at the party,

2015-03-24 22:42:43 475

原创 Probability|Given - UVa 11181 概率dp

Problem GProbability|GivenInput: Standard InputOutput: Standard Output N friends go to the local super market together. The probability of their buying something from the market is respectiv

2015-03-24 22:22:23 406

原创 "Shortest" pair of paths - POJ 3068 费用流

"Shortest" pair of pathsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 1066 Accepted: 421DescriptionA chemical company has an unusual shortest path p

2015-03-20 22:34:28 555

原创 Eat or Not to Eat? - UVa 10273 暴力

题意:给你n头奶牛,以及他们的周期产奶量,如果有一天只有一头奶牛产奶量最少,那么就杀掉这头牛,问最后有多少牛存活,并且最后杀死一头奶牛的时间。思路:首先算出所有的周期的最小公倍数,如果这段时间内有奶牛被杀的话,那么重新计算,否则说明不会再有奶牛被杀。AC代码如下:#include#includeusing namespace std;int T,t,n,pre[1010],nex

2015-03-20 16:10:19 595

原创 Adventure of Super Mario - UVa 10269 Floyd+Dijkstra

题意:有n个村庄,m个城堡,马里奥需要从n+m点的城堡回到1的村庄,同时,他有一双鞋每次使用可以连续飞行不超过L的距离,但是起点和终点必须是村庄或城堡,并且中间不能经过城堡,而且最多用k次,问他回到家的最短时间是多少。思路:首先Floyd找出所有只以村庄作为中转点的每两个点间的最短距离,然后dp[u][k]表示到u点并且鞋子还可以用k次的最少花费时间。通过Dijkstra求得最后的答案。A

2015-03-18 17:50:18 473

原创 Game Show Math - UVa10400 搜索

Game Show MathInput: standard inputOutput: standard outputTime Limit: 15 secondsA game show in Britain has a segment where it gives its contestants a sequence of positive numbers and a tar

2015-03-17 17:35:55 364

原创 Fishnet - UVa 1301 几何

题意:给你一个(n+1)*(n+1)的网,让你求出最大的四边形的面积。思路:用几何的两条直线求交点,算出四个端点,然后转化成两个三角形求面积。AC代码如下:#include#include#include#includeusing namespace std;struct Point{ double x,y; Point(double x=0,double

2015-03-17 16:18:06 433

原创 Fighting Against a Polygonal Monster - UVa 11177 圆和凸包面积的交

题意:给你一个凸包,求圆的最小半径使得面积的并>R。思路:二分这个半径,然后就是纯几何模板了,不知道为什么long double 就能过,double就会WA。反正UVa经常会出现神奇的现象,我表示已经习惯了。AC代码如下:#include#include#include#include#includeusing namespace std;struct Point{

2015-03-15 22:41:14 737

原创 Urn-ball Probabilities! - UVa 10169

题意:一开始,一个壶里有一个红球,一个壶里有一个红球和一个白球,每次从两个壶中各拿出一个球,放回后再向两个壶中各放入一个白球。问至少有一次同时拿到两个红球的概率,和一直拿到红球的概率的小数点后有多少个0。思路:简单的概率递推,打表实现,没什么好说的。AC代码如下:#include#includeusing namespace std;typedef long long ll;d

2015-03-10 22:22:52 445

原创 Boastin' Red Socks - UVa 10277

题意:共有n个袜子,其中红袜子m只,告诉你拿到两只袜子都是红袜子的概率为p/q,问在袜子数最少的情况下,有多少红袜子,多少黑袜子。思路:m*(m-1)  /   n*(n-1) =p/q 那么 每次枚举n,可以得到 m*(m-1)= n*(n-1)*p/q,用map存储所有的m可以表示的数量,这样可以快速得到m。AC代码如下:#include#include#include#in

2015-03-10 21:53:58 428

原创 France '98 - UVa 542 概率dp

France '98 Today the first round of the Soccer World Championship in France is coming to an end. 16 countries are remaining now, among which the winner is determined by the following tournament:

2015-03-10 21:14:22 543

原创 A and B and Interesting Substrings - CodeForces 519 D dp

A and B and Interesting Substringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA and B are preparing th

2015-03-02 08:38:23 574

原创 Copying Books - UVa 714 dp

Copying Books Before the invention of book-printing, it was very hard to make a copy of a book. All the contents had to be re-written by hand by so called scribers. The scriber had been given a

2015-03-02 08:33:12 614

原创 Add All - UVa 10954 优先队列

Add AllInput: standard inputOutput: standard outputYup!! The problem name reflects your task; just add a set of numbers. But you may feel yourselves condescended, to write a C/C++ program ju

2015-03-02 08:27:39 430

原创 Minimal coverage - UVa 10020 贪心

题意:用最少的线铺满0-m。思路:贪心,每次找到当前状态下能铺到的最远的线。AC代码如下:#include#include#includeusing namespace std;struct node{ int l,r,num;}line[100010];bool cmp(node a,node b){ return a.l<b.l;}int T,t

2015-03-01 15:37:28 478

空空如也

空空如也

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

TA关注的人

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