Children are always sweet but they can sometimesmake you feel bitter. In this problem, you will see how Tintin, a five year’sold boy, creates trouble for his parents. Tintin is a joyful boy and is alw...
分类:
其他好文 时间:
2014-08-17 20:00:42
阅读次数:
291
题目链接:uva 1404 1404 - Prime k-tuple
题目大意:如果k个相邻的素数p1,p2,…,pk,满足pk?p1=s,称这些素数组成一个距离为s的素数k元组,给定区间a,b,求有多少个距离s的k元组。
解题思路:筛选素数法,先预处理出[1, sqrt(inf)]的素数表,然后对给定区间[a,b]根据预处理出的素数表筛选出素数即可。
#include
#incl...
分类:
其他好文 时间:
2014-08-17 17:07:42
阅读次数:
211
UVA 11107 - Life Forms
题目链接
题意:给定一个字符串,找出重复出现超过m次的字串的最大开始下标
思路:hash大法,需要点人品,然后二分答案,每次利用hash值去找出最大下标即可
代码:
#include
#include
#include
using namespace std;
typedef unsigned long long ...
分类:
其他好文 时间:
2014-08-17 17:04:52
阅读次数:
650
Treblecross is a two player gamewhere the goal is to get three X in a row on a one-dimensional board. At the startof the game all cells in the board is empty. In each turn a player puts a X in an empt...
分类:
其他好文 时间:
2014-08-17 17:03:33
阅读次数:
358
Division game is a 2-player game.In this game, there is a matrix of positive integers with N rows and M columns.Players make their moves in turns. In each step, the current player selects arow. If the...
分类:
其他好文 时间:
2014-08-17 15:40:52
阅读次数:
191
UVA 1492 - Adding New Machine
题目链接
题意:给定一些旧机器管辖范围,现在要放一台进新机器,新机器需要空间1*m,问有多少种放法
思路:转化为求面积并的问题,先考虑横放,对于旧机器左边m个位置肯定不能放,还有边界w-m之后的位置肯定不能放,这样就可以把旧机器向左扩大m个位置,并且边界多上一块m*h大小的面积,这样求出这些面积并再用总面积减去即可,求面...
分类:
其他好文 时间:
2014-08-17 15:40:02
阅读次数:
245
Description
You and your friend are playing a game in which you and your friend take turns removing stones from piles. Initially there are
N piles with a1,
a2, a3,..., aN number of stones. On eac...
分类:
其他好文 时间:
2014-08-17 11:46:42
阅读次数:
172
刘汝佳 算法入门 第一版 Uva题目集合(四)...
分类:
其他好文 时间:
2014-08-17 10:28:12
阅读次数:
294
OpenCreditSystemInput:StandardInputOutput:StandardOutputInanopencreditsystem,thestudentscanchooseanycoursetheylike,butthereisaproblem.Someofthestudent...
分类:
其他好文 时间:
2014-08-17 10:20:02
阅读次数:
286
Robot InstructionsYou have a robot standing on the origin ofxaxis. The robot will be given some instructions. Your task is to predict its position aft...
分类:
其他好文 时间:
2014-08-17 02:27:21
阅读次数:
242