摘要: Description You are given two pots, having the volume of A and B liters respectively. The following operations can be performed: FILL(i) fill the pot  阅读全文
posted @ 2017-07-25 10:03 whileskies 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 1050 循环数组最大子段和 N个整数组成的循环序列a[1],a[2],a[3],…,a[n],求该序列如a[i]+a[i+1]+…+a[j]的连续的子段和的最大值(循环序列是指n个数围成一个圈,因此需要考虑a[n-1],a[n],a[1],a[2]这样的序列)。当所给的整数均为负数时和为0。 例如 阅读全文
posted @ 2017-07-23 21:53 whileskies 阅读(209) 评论(0) 推荐(0) 编辑
摘要: n个人,已知每个人体重。独木舟承重固定,每只独木舟最多坐两个人,可以坐一个人或者两个人。显然要求总重量不超过独木舟承重,假设每个人体重也不超过独木舟承重,问最少需要几只独木舟? Input 第一行包含两个正整数n (0<n<=10000)和m (0<m<=2000000000),表示人数和独木舟的承 阅读全文
posted @ 2017-07-22 17:26 whileskies 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 将一堆正整数分为2组,要求2组的和相差最小。 例如:1 2 3 4 5,将1 2 4分为1组,3 5分为1组,两组和相差1,是所有方案中相差最少的。 Input 第1行:一个数N,N为正整数的数量。 第2 - N+1行,N个正整数。 (N <= 100, 所有正整数的和 <= 10000) Outp 阅读全文
posted @ 2017-07-22 16:18 whileskies 阅读(267) 评论(0) 推荐(0) 编辑
摘要: 有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整: fun(A) sum = 0 for i = 1 to A.length for j = i+1 to A.length sum = sum + Floor((A[i]+A[j])/(A[i]*A[j])) return s 阅读全文
posted @ 2017-07-21 23:15 whileskies 阅读(343) 评论(0) 推荐(0) 编辑
摘要: poj 1222 EXTENDED LIGHTS OUT 开关只有两种方案 按和不按,按两次相当于关 只用枚举第一排开关的按法即可,剩下的行为使上一排的灯全部关闭,按法可以确定,并且是唯一的。 最后检查最后一行是否都为0,都为0为可行的方案。 用位运算来实现。 #include <iostream> 阅读全文
posted @ 2017-07-20 15:12 whileskies 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 描述 一个字符串的前缀是从该字符串的第一个字符起始的一个子串。例如 "carbon"的字串是: "c", "ca", "car", "carb", "carbo", 和 "carbon"。注意到这里我们不认为空串是字串, 但是每个非空串是它自身的字串. 我们现在希望能用前缀来缩略的表示单词。例如, 阅读全文
posted @ 2017-07-19 00:02 whileskies 阅读(1311) 评论(0) 推荐(0) 编辑
摘要: Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater locate 阅读全文
posted @ 2017-07-16 19:13 whileskies 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 描述As we known, data stored in the computers is in binary form. The problem we discuss now is about the positive integers and its binary form.Given a p 阅读全文
posted @ 2017-07-16 15:58 whileskies 阅读(431) 评论(0) 推荐(0) 编辑
摘要: Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,00 阅读全文
posted @ 2017-07-15 10:41 whileskies 阅读(177) 评论(0) 推荐(0) 编辑