摘要: 题目:Problem DescriptionClaire and her little friend, ykwd, are travelling in Shevchenko's Park! The park is beautiful - but large, indeed. N feature spots in the park are connected by exactly (N-1) undirected paths, and Claire is too tired to visit all of them. After consideration, she decides to 阅读全文
posted @ 2013-08-19 18:29 lysr__tlp 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 题目:Problem DescriptionFatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 2 #include 3 using namespace std; 4 5 int dp[105][105],map[105][105]; 6 int n,k,sum; 7 8 int dfs( int x, int y ) { 9 10 if(... 阅读全文
posted @ 2013-08-19 17:35 lysr__tlp 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 题目:Problem DescriptionA有1数m,B来猜.B每猜一次,A就说"太大","太小"或"对了" 。问B猜n次可以猜到的最大数。Input第1行是整数T,表示有T组数据,下面有T行每行一个整数n (1 ≤ n ≤ 30)Output猜n次可以猜到的最大数Sample Input213Sample Output17参考 :http://hi.baidu.com/xiao_yu_feng/item/3fdcf0f07ad18017d6ff8c69在1到m间,你最多只要猜log2(m)+1(取整)次,所以易知==>m=2 阅读全文
posted @ 2013-08-18 17:31 lysr__tlp 阅读(250) 评论(0) 推荐(0) 编辑
摘要: (简单的01背包)题目:Problem Description现有一笔经费可以报销一定额度的发票。允许报销的发票类型包括买图书(A类)、文具(B类)、差旅(C类),要求每张发票的总额不得超过1000元,每张发票上,单项物品的价值不得超过600元。现请你编写程序,在给出的一堆发票中找出可以报销的、不超过给定额度的最大报销额。Input测试输入包含若干测试用例。每个测试用例的第1行包含两个正数 Q 和 N,其中 Q 是给定的报销额度,N( 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 int Value[35],dp.. 阅读全文
posted @ 2013-08-18 11:39 lysr__tlp 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 题目:Problem Description小明和他的好朋友小西在玩一个游戏,由电脑随机生成一个由-2,0,2三个数组成的数组,并且约定,谁先算出这个数组中某一段连续元素的积的最大值,就算谁赢!比如我们有如下随机数组:2 2 0 -2 0 2 2 -2 -2 0在这个数组的众多连续子序列中,2 2 -2 -2这个连续子序列的积为最大。现在小明请你帮忙算出这个最大值。Input第一行输入一个正整数T,表示总共有T组数据(T <= 200)。接下来的T组数据,每组数据第一行输入N,表示数组的元素总个数(1<= N <= 10000)。再接下来输入N个由0,-2,2组成的元素,元素 阅读全文
posted @ 2013-06-10 18:38 lysr__tlp 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 题目:Problem DescriptionFJ is surveying his herd to find the most average cow. He wants to know how much milk this 'median' cow gives: half of the cows give as much or more than the median; half give as much or less.Given an odd number of cows N (1 <= N < 10,000) and their milk output (1 阅读全文
posted @ 2013-06-08 19:33 lysr__tlp 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 题目:CubeProblem DescriptionCowl is good at solving math problems. One day a friend asked him such a question: You are given a cube whose edge length is N, it is cut by the planes that was paralleled to its side planes into N * N * N unit cubes. Two unit cubes may have no common points or two common p 阅读全文
posted @ 2013-06-03 16:54 lysr__tlp 阅读(554) 评论(0) 推荐(0) 编辑
摘要: 输入第一行有一个整数n(0<n<10000),表示有n组测试数据;接下来n行每行有一个整数 m(1<m<10000)输出从小到大输出m分解成素因子相乘后各个素因子对应的指数样例输入2553样例输出3 1 149 23 12 8 4 4 3 2 2 1 1 1 1 1 1 1 主要是解决超时问题,找因子时要进行优化。只有素数才可能是因子,因此可以将素数存起来,对2到n的所有数找因子的时候,就可直接通过prim数组(存素数的)进行整除,就可以省去很多时间了。代码: 1 2 #include<stdio.h> 3 #include<string.h> 阅读全文
posted @ 2013-05-30 00:18 lysr__tlp 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 题目:描述世界末日马上就要来临了,当然,每个人都想买到船票,但是由于船票有限,因此需要回答对一个问题才能买票。问题是这样的:给你一个数n (1 <= n <= 10000),之后给n个正整数 (<= 10000),问在这n个数中是否存在一些数的和是n的倍数。输入多组测试数据(最多100组)。首先输入一个数n,然后输入n个数。输出如果能找到一些数的和是n的倍数,输出"YES",否则输出"NO"。样例输入55 3 6 7 9样例输出YES代码: 1 #include<stdio.h> 2 int main() 3 { 4 int 阅读全文
posted @ 2013-05-29 23:57 lysr__tlp 阅读(285) 评论(0) 推荐(0) 编辑
摘要: 一个sort就能解决,结果因为粗心,调代码的时候只改了一个地方,忘了另一个地方,刚好样例输出正确,就这样wa了。总之就是没有处理好数的个数问题啦!代码: 1 #include<stdio.h> 2 #include<algorithm> 3 using namespace std; 4 struct num 5 { 6 int mmm;// 数本身 7 int mm;// 反序后的数 8 9 }Y[55];10 bool pp(num a,num b)11 {12 return a.mm<b.mm;13 }14 int main()15 {16 ... 阅读全文
posted @ 2013-05-15 00:15 lysr__tlp 阅读(142) 评论(0) 推荐(0) 编辑