上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 19 下一页

2013年4月5日

UVa10037 - Bridge

摘要: 题目大意在一个晚上有N个人过河,他们总共只有一个手电筒,需要有手电筒才能过河,每次最多两个人同时过河,每个人的过河速度都不同,所以每次过河时间等于速度最慢的那个人的过河时间,让所有人全部过河,花费的时间最少是多少?题解如果只有一个人过河,那么过河的总时间就是这个人过河的时间。如果是两个人过河,那么总时间为过河速度较慢的那个人的过河时间。如果是三个人过河,假设速度从慢到快分别为a,b,c,分别用A,B,C表示三个人,那么我们会先让A和C一起过河,然后A返回,之后再让A和B一起过河,总花费时间为a+b+c。当人数大于等于4时,我们每次都让两个速度最慢的人过河,让这两个人过河我们有两种策略(其他过河 阅读全文

posted @ 2013-04-05 17:39 仗剑奔走天涯 阅读(256) 评论(0) 推荐(0) 编辑

2013年4月4日

UVa11078 - Open Credit System

摘要: 题目大意给定一个长度为N的序列A,找出两个整数A[i]和A[j](i<j),使得A[i]-A[j]尽量大题解最简单的做法就是直接用二重循环枚举A[i]和A[j],不过对于N=10000的数据量显然会超时。对于每个j,我们要找到最大的A[i],只要在枚举j的时候顺便用一个变量维护一下A[i]的最大值就行,这样时间复杂度就由O(N^2)降低到O(N)了。代码#include<stdio.h>#include<stdlib.h>#define MAXN 100005#define INF 0x7ffffffflong a[MAXN];long MAXS;long max 阅读全文

posted @ 2013-04-04 00:37 仗剑奔走天涯 阅读(171) 评论(0) 推荐(0) 编辑

2013年4月3日

POJ3279 - Fliptile

摘要: 题目大意给定一个N*M的网格,每个网格里有一个数字,0或者1,要求你翻转尽量少的网格,使得所有网格的数字都变为0,对于某一个网格进行翻转操作时,与它有公共边的网格全部会被翻转。题解和Uva11464的方法一样,都是枚举第一行的状态,只要第一行的状态确定了,那么每行的状态都确定了。代码#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAXN 20int a[MAXN][MAXN],b[MAXN][MAXN],ans[MAXN][MAXN];int n,m;int check(int s) 阅读全文

posted @ 2013-04-03 18:11 仗剑奔走天涯 阅读(796) 评论(1) 推荐(0) 编辑

HDOJ1003 - Max Sum

摘要: 题目大意:和1231一样,求最大连续子序列和,只是这个题目是要求求的是最大连续子序列和的首元素位置和尾元素位置。题解:直接把1231的代码稍微修改一下就行了。。。#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAXN 100005typedef struct{ long x,y;} NODE;NODE path[MAXN];long d[MAXN],a[MAXN];int main(void){ long i,n,maxs,l,r,T,p; scanf("%ld" 阅读全文

posted @ 2013-04-03 00:04 仗剑奔走天涯 阅读(187) 评论(0) 推荐(0) 编辑

2013年4月2日

HDOJ1231 - 最大连续子序列

摘要: 题目大意:求最大连续子序列和,并输出其序列的首元素和尾元素。题解:方程非常简单:d[i]=max(0,d[j-1])+a[i],主要是最大连续子序列和的首元素和尾元素怎么记录的问题,其实也非常简单,就是在当我们求以位置i为结束位置的最大连续子序列和的时候,顺便记录下以位置i结束的最大连续子序列和的首元素和尾元素,如果序列的长度为1,则尾元素和首元素都是a[i],如果大于1,则首元素为d[i-1]的首元素,尾元素依然是a[i]。#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAXN 1 阅读全文

posted @ 2013-04-02 23:46 仗剑奔走天涯 阅读(141) 评论(0) 推荐(0) 编辑

2013年3月31日

第一次月赛总结

摘要: 五个小时11道题目。我总共A出四道,rank1。。。,还有两道一直WA。A.就是一语文题。。。HLM学长太没节操了。B.原题,HDU2021,直接模拟。。。C.HDU2103,很水的题目,我居然一直WA。。。,好像是没考虑0的情况。D.无聊的数学题。。不会。。。E.赤裸裸的floodfillF.USACO原题,USACO2.4.5。这题也是很水的模拟,并且我都已经做过了,居然一直WA,我真他妈是脑残啊!!!在处理小数部分被整除的i情况忘记输出回车了(就是每行只能输出76个字符)G.数学题,求方程的根,二分答案H.又是数学题,LZH大神貌似好喜欢出数学题。。。I.POJ1691,搜索题目。J.U 阅读全文

posted @ 2013-03-31 02:08 仗剑奔走天涯 阅读(190) 评论(0) 推荐(0) 编辑

2013年3月29日

UVa1153 - Keep the Customer Satisfied

摘要: Simon and Garfunkel Corporation (SG Corp.) is a large steel-making company with thousand of customers. Keeping the customer satisfied is one of the major objective of Paul and Art, the managers.Customers issue orders that are characterized by two integer valuesq, the amount of steel required (in ton 阅读全文

posted @ 2013-03-29 00:36 仗剑奔走天涯 阅读(541) 评论(0) 推荐(0) 编辑

2013年3月28日

Uva1420 - Priest John's Busiest Day

摘要: John is the only priest in his town. October 26th is the John's busiest day in a year because there is an old legend in the town that the couple who get married on that day will be forever blessed by the God of Love. This yearNcouples plan to get married on the blessed day. Thei-th couple plan t 阅读全文

posted @ 2013-03-28 23:56 仗剑奔走天涯 阅读(250) 评论(0) 推荐(0) 编辑

UVa1467 - Installations

摘要: In the morning, service engineers in a telecom company receive a list of jobs which they must serve today. They install telephones, internet, ipTVs, etc and repair troubles with established facilities. A client requires a deadline when the requested job must be completed. But the engineers may not c 阅读全文

posted @ 2013-03-28 00:19 仗剑奔走天涯 阅读(379) 评论(0) 推荐(1) 编辑

2013年3月27日

UVa1335 - Beijing Guards

摘要: Beijing was once surrounded by four rings of city walls: the Forbidden City Wall, the Imperial City Wall, the Inner City Wall, and finally the Outer City Wall. Most of these walls were demolished in the 50s and 60s to make way for roads. The walls were protected by guard towers, and there was a guar 阅读全文

posted @ 2013-03-27 16:40 仗剑奔走天涯 阅读(328) 评论(0) 推荐(0) 编辑

UVa1445 - Cubist Artwork

摘要: International Center for Picassonian Cubismis a Spanish national museum of cubist artworks, dedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed in front of the facade of the museum building. The artwork is a collection of cubes that are piled up on the gro 阅读全文

posted @ 2013-03-27 13:56 仗剑奔走天涯 阅读(244) 评论(0) 推荐(0) 编辑

2013年3月26日

UVa11134 - Fabled Rooks

摘要: Problem F: Fabled RooksWe would like to placenrooks, 1≤n≤5000, on an×nboard subject to the following restrictionsThei-th rook can only be placed within the rectangle given by its left-upper corner (xli,yli) and its right-lower corner (xri,yri), where 1≤i≤n, 1≤xli≤xri≤n, 1≤yli≤yri≤n.... 阅读全文

posted @ 2013-03-26 18:53 仗剑奔走天涯 阅读(405) 评论(0) 推荐(0) 编辑

2013年3月25日

UVa11462 - Age Sort

摘要: BAge SortInput:Standard InputOutput:Standard OutputYou are given the ages (in years) of all people of a country with at least 1 year of age. You know that no individual in that country lives for 100 or more years. Now, you are given a very simple task of sorting all the ages in ascending order.Input 阅读全文

posted @ 2013-03-25 18:40 仗剑奔走天涯 阅读(175) 评论(0) 推荐(0) 编辑

UVa11100 - The Trip, 2007

摘要: Problem A: The Trip, 2007A number of students are members of a club that travels annually to exotic locations. Their destinations in the past have included Indianapolis, Phoenix, Nashville, Philadelphia, San Jose, Atlanta, Eindhoven, Orlando, Vancouver, Honolulu, Beverly Hills, Prague, Shanghai, and 阅读全文

posted @ 2013-03-25 15:06 仗剑奔走天涯 阅读(225) 评论(0) 推荐(0) 编辑

UVa11389 - The Bus Driver Problem

摘要: IIUCONLINE CONTEST2008Problem E: The Bus Driver ProblemInput: standard inputOutput: standard outputIn a city there arenbus drivers. Also there arenmorning bus routes &nafternoon bus routes with various lengths. Each driver is assigned one morning route & one evening route. For any driver, if 阅读全文

posted @ 2013-03-25 11:51 仗剑奔走天涯 阅读(287) 评论(0) 推荐(0) 编辑

上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 19 下一页

导航