自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 循环赛日程表问题

相信循环日程表问题大家都不陌生,我们很容易想到一个分治的方法来求解此问题,今天碰巧遇到了一种非递归的解法,mark一下,该解法是利用多边形来进行求解的,具体的求解过程参照此博客:http://blog.csdn.net/yuanyirui/article/details/3891359,他在解决8人的循环日程表的时候采用的是七边形,我在图上画了一下我们完全可以在参加循环赛的人数为n时利用n边形的求

2015-06-30 12:11:25 420

原创 1105 第K大的数

数组A和数组B,里面都有n个整数。数组C共有n^2个整数,分别是A[0] * B[0],A[0] * B[1] ......A[1] * B[0],A[1] * B[1]......A[n - 1] * B[n - 1](数组A同数组B的组合)。求数组C中第K大的数。例如:A:1 2 3,B:2 3 4。A与B组合成的C包括2 3 4 4 6 8 6 9 12共9个数。

2015-06-28 12:46:34 497

原创 51Nod 1103 N的倍数

一个长度为N的数组A,从A中选出若干个数,使得这些数的和是N的倍数。例如:N = 8,数组A包括:2 5 6 3 18 7 11 19,可以选2 6,因为2 + 6 = 8,是8的倍数。Input第1行:1个数N,N为数组的长度,同时也是要求的倍数。(2 <= N <= 50000)第2 - N + 1行:数组A的元素。(0 OutPut如果没有符

2015-06-26 22:35:27 667

原创 Codeforces 515C Drazil and Factorial

Drazil is playing a math game with Varda.Let's define  for positive integer x as a product of factorials of its digits. For example, .First, they choose a decimal number a consisting of n di

2015-06-26 20:19:27 595

转载 斐波那契博弈(Fibonacci Nim)

本文出自: http://blog.csdn.net/dgq8211/article/details/7602807有一堆个数为n(n>=2)的石子,游戏双方轮流取石子,规则如下:1)先手不能在第一次把所有的石子取完,至少取1颗;2)之后每次可以取的石子数至少为1,至多为对手刚取的石子数的2倍。约定取走最后一个石子的人为赢家,求必败态。结论:当n

2015-06-26 15:14:23 447

原创 HDU 4542 小明系列故事——未知剩余系

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4542参考了ACdreamer的博客:http://blog.csdn.net/ACdreamers/article/details/25049767首先对于本题(1)Type = 0即求解约数个数为K结果是一定存在,只不过存在超出范围和不超出范围两种情况,这个与反素数有关,

2015-06-26 11:07:32 680

原创 51Nod 1060 最复杂的数

把一个数的约数个数定义为该数的复杂程度,给出一个n,求1-n中复杂程度最高的那个数。例如:12的约数为:1 2 3 4 6 12,共6个数,所以12的复杂程度是6。如果有多个数复杂度相等,输出最小的。Input第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 100)第2 - T + 1行:T个数,表示需要计算的n。(1 OutPut

2015-06-25 23:14:07 713

原创 Codeforces 27E Number With The Given Amount Of Divisors

Given the number n, find the smallest positive integer which has exactlyn divisors. It is guaranteed that for the givenn the answer will not exceed 1018.InputThe first line of the input

2015-06-25 22:23:53 420

原创 Codeforces 553C Love Triangles

There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters

2015-06-25 18:02:08 1486

原创 Codeforces 553B Kyoya and Permutation

Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1,

2015-06-25 15:23:04 645

原创 Codeforces 553A Kyoya and Colored Balls

Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labeled from 1 to k. Balls of the same color are indistinguishable. He draws balls from the bag

2015-06-25 10:13:43 506

原创 Codeforces 554B Ohana Cleans Up

Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her

2015-06-25 09:41:35 441

原创 Codeforces 554A Kyoya and Photobooks

Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with

2015-06-25 09:26:15 522

原创 Codeforces 552E Vanya and Brackets

Vanya is doing his maths homework. He has an expression of form , wherex1, x2, ..., xn are digits from1 to 9, and sign represents either a plus '+' or the multiplication sign '*'. Vanya needs t

2015-06-23 21:39:47 440

原创 Codeforces 552E Vanya and Brackets

Vanya is doing his maths homework. He has an expression of form , wherex1, x2, ..., xn are digits from1 to 9, and sign represents either a plus '+' or the multiplication sign '*'. Vanya needs t

2015-06-23 19:16:04 453

原创 Codeforces 552D Vanya and Triangles

Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points.

2015-06-23 19:13:37 534

原创 Codeforces 552C Vanya and Scales

Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams wherew is some integer not less than 2 (exactly one weight of each nominal value). Vanya wonders whether h

2015-06-23 17:03:43 960

原创 ZOJ 3471 Most Powerful

Recently, researchers on Mars have discovered N powerful atoms. All of them are different. These atoms have some properties. When two of these atoms collide, one of them disappears and a lot of power

2015-06-23 12:00:13 504

原创 POJ 2288 Islands and Bridges

DescriptionGiven a map of islands and bridges that connect these islands, a Hamilton path, as we all know, is a path along the bridges such that it visits each island exactly once. On our map, the

2015-06-23 11:11:50 377

原创 HDU 3001 Travelling

Problem DescriptionAfter coding so many days,Mr Acmer wants to have a good rest.So travelling is the best choice!He has decided to visit n cities(he insists on seeing all the cities!And he does not

2015-06-23 09:54:31 431

原创 POJ 3311 Hie with the Pie

DescriptionThe Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can afford to hire only one driver to do the deliveries

2015-06-23 09:16:31 394

原创 POJ 3254 Corn Fields

DescriptionFarmer John has purchased a lush new rectangular pasture composed of M byN (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of square

2015-06-22 12:07:32 442

原创 POJ 2441 Arrange the Bulls

DescriptionFarmer Johnson's Bulls love playing basketball very much. But none of them would like to play basketball with the other bulls because they believe that the others are all very weak. Farme

2015-06-22 10:31:54 443

原创 POJ 1185 炮兵阵地

Description司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表示),如下图。在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队);一支炮兵部队在地图上的攻击范围如图中黑色区域所示:如果在地图中的灰色所标识的平原上部署一支炮兵部队,则图中的黑色的网格表

2015-06-21 15:02:44 1139

原创 SGU 223 Little Kings

After solving nice problems about bishops and rooks, Petya decided that he would like to learn to play chess. He started to learn the rules and found out that the most important piece in the game is t

2015-06-21 11:02:57 482

原创 HDU 3485 Count 101

Problem DescriptionYou know YaoYao is fond of his chains. He has a lot of chains and each chain has n diamonds on it. There are two kinds of diamonds, labeled 0 and 1. We can write down the label of

2015-06-19 18:40:20 531

原创 HDU 3506 Monkey Party

Far away from our world, there is a banana forest. And many lovely monkeys live there. One day, SDH(Song Da Hou), who is the king of banana forest, decides to hold a big party to celebrate Crazy Banan

2015-06-19 17:58:46 624

原创 POJ 1083 Moving Tables

The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.The floor has 200 rooms each on the north side and south side along the

2015-06-19 16:14:29 614

原创 Eclipse配色方案插件

最近发现了一个Eclipse配色方案插件,这回给Eclipse配色太方便了。插件主页:http://eclipsecolorthemes.org/插件提供了上万种配色方案,非常漂亮,上图看下:安装很简单,打开 Eclipse Marketplace查找 Eclipse Color Theme,会找到这个插件。安装完成后进入 Pre

2015-06-19 12:17:47 427

原创 CF 551D GukiZ and Binary Operations

We all know that GukiZ often plays with arrays. Now he is thinking about this problem: how many arrays a, of length n, with non-negative elementsstrictly less then 2l meet the following condit

2015-06-18 22:14:58 680

原创 551C GukiZ hates Boxes

Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way.In total there are n piles of boxes, arranged in a line, from left to right,i-th

2015-06-18 21:13:39 700

原创 551B ZgukistringZ

Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one.GukiZ has strings a, b, and c. He wants to obtain stringk by swapping some letters

2015-06-18 17:29:35 1036

转载 经典位操作

最近看了一篇文章>感觉不错,适当的做一下笔记。原文地址:http://graphics.stanford.edu/~seander/bithacks.html#OperationCounting1、Compute the sign of an integer // we want to find the sign of v int v; // the re

2015-06-18 09:45:37 944

转载 Detect if two integers have opposite signs

来源: http://www.geeksforgeeks.org/detect-if-two-integers-have-opposite-signs/不采用算术运算符,我们可以采用以下几种方法。(1) 首先异或操作可以判断两个数是否是同号的,因为异或运算是将符号位包括在内的,非负数符号位为0,负数符号位为1,所以0^1=1,异或的结果符号位1,即为负数。#includ

2015-06-17 23:14:59 456

转载 Find the element that appears once

来源:http://www.geeksforgeeks.org/find-the-element-that-appears-once/问题:在一个数组中,其中有一个元素只出现一次,其余元素都出现三次,如何在O(n)的时间复杂度和O(1)的复杂度内找到那个元素。首先我的想法是,一个数如果出现了三次,则这个数的二进制对应的位上1的个数肯定为3.这样我们可以枚举每一位,计算所有数

2015-06-17 22:17:28 384

原创 Maximal Square

Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0

2015-06-17 21:27:26 456

原创 Best Time to Buy and Sell Stock IV

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:You may no

2015-06-17 20:58:10 529

原创 Best Time to Buy and Sell Stock II

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on

2015-06-17 20:44:38 370

原创 Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total numb

2015-06-17 19:40:15 412

原创 House Robber II

After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this place are arranged in a ci

2015-06-17 19:26:43 363

空空如也

空空如也

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

TA关注的人

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