第一届省赛 Phone Number
摘要:题目描述 We know that if a phone number A is another phone number B’s prefix, B is not able to be called. For an example, A is 123 while B is 12345, ...
阅读全文
posted @
2015-04-29 19:44
星斗万千
阅读(327)
推荐(0)
POJ 1418 Viva Confetti
摘要:Description Do you know confetti? They are small discs of colored paper, and people throw them around during parties or festivals. Since people ...
阅读全文
posted @
2015-04-29 16:29
星斗万千
阅读(166)
推荐(0)
第一届省赛 Ivan comes again! (set)
摘要:题目描述 The Fairy Ivan gave Saya three problems to solve (Problem F). After Saya finished the first problem (Problem H), here comes the second. This...
阅读全文
posted @
2015-04-28 21:09
星斗万千
阅读(170)
推荐(0)
第一届省赛 Emergency 最短路
摘要:题目描述 Kudo’s real name is not Kudo. Her name is Kudryavka Anatolyevna Strugatskia, and Kudo is only her nickname. Now, she is facing an emergency ...
阅读全文
posted @
2015-04-28 21:06
星斗万千
阅读(140)
推荐(0)
数据结构-顺序表和链表的基本操作
摘要:小武老师布置的题,让我们分别用顺序表和链表的形式完成一些操作,虽然本人还没验收但还是发这篇博客吧,我就是这么任性。 实验内容 该程序的功能是对元素类型为整型的顺序表进行一些操作。该程序包括顺序表结构类型的定义以及对顺序表操作的具体的函数定义和主函数。 此题我使用了一些对于界面好看点的程序代码...
阅读全文
posted @
2015-04-28 18:05
星斗万千
阅读(448)
推荐(0)
UVA 12304 2D Geometry 110 in 1!(计算几何)
摘要:This is a collection of 110 (in binary) 2D geometry problems. CircumscribedCircle x1 y1 x2 y2 x3 y3 Find out the circumscribed circle of triangle (x...
阅读全文
posted @
2015-04-28 10:33
星斗万千
阅读(282)
推荐(0)
bestcoder Mutiple
摘要:问题描述 wld有一个序列a[1..n], 对于每个1≤i using namespace std; int main() { int n; while(cin>>n) { int num[10010]={0},sum=0; for(in...
阅读全文
posted @
2015-04-26 21:05
星斗万千
阅读(118)
推荐(0)
bestcoder Delete
摘要:问题描述 wld有n个数(a1,a2,...,an),他希望进行k次删除一个数的操作,使得最后剩下的n−k个数中有最多的不同的数,保证1≤n≤100,0≤k #include using namespace std; struct node { int data; int c...
阅读全文
posted @
2015-04-26 21:04
星斗万千
阅读(113)
推荐(0)
UVA 11796 Dog Distance
摘要:注意最后结果是四舍五入到最近的整数 #include #include #include using namespace std; double Min,Max; struct Point { double x,y; Point(){} Point(dou...
阅读全文
posted @
2015-04-25 21:09
星斗万千
阅读(139)
推荐(0)
POJ 2284 That Nice Euler Circuit (欧拉定理)
摘要:Description Little Joey invented a scrabble machine that he called Euler, after the great mathematician. In his primary school Joey heard about the...
阅读全文
posted @
2015-04-25 19:41
星斗万千
阅读(193)
推荐(0)
UVA 11178 Morley’s Theorem(计算几何直线的交点)
摘要:Morley’s theorem states that that the lines trisecting the angles of an arbitrary plane triangle meet at the vertices of an equilateral triangle. Fo...
阅读全文
posted @
2015-04-25 18:41
星斗万千
阅读(196)
推荐(0)
HDU 1215 七夕节
摘要:Problem Description 七夕节那天,月老来到数字王国,他在城门上贴了一张告示,并且和数字王国的人们说:"你们想知道你们的另一半是谁吗?那就按照告示上的方法去找吧!" 人们纷纷来到告示前,都想知道谁才是自己的另一半.告示如下: 数字N的因子就是所有比N小又能被N整除的所有正整数...
阅读全文
posted @
2015-04-24 10:37
星斗万千
阅读(124)
推荐(0)
HDU 1164 Eddy's research I.doc
摘要:Problem Description Eddy's interest is very extensive, recently he isinterested in prime number. Eddy discover the all number owned can be dividedin...
阅读全文
posted @
2015-04-24 10:33
星斗万千
阅读(111)
推荐(0)
HDU 1024 Max Sum Plus Plus
摘要:Problem Description Now I thinkyou have got an AC in Ignatius.L's "Max Sum" problem. To be a braveACMer, we always challenge ourselves to more diffi...
阅读全文
posted @
2015-04-24 10:31
星斗万千
阅读(125)
推荐(0)
HDU 1006 Tick and Tick
摘要:ProblemDescription The three hands of theclock are rotating every second and meeting each other many times everyday.Finally, they get bored of this ...
阅读全文
posted @
2015-04-24 10:30
星斗万千
阅读(150)
推荐(0)
HDU 1007 Quoit Design
摘要:Problem Description Have you ever played quoit in a playground? Quoit is agame in which flat rings are pitched at some toys, with all the toys encir...
阅读全文
posted @
2015-04-24 10:30
星斗万千
阅读(191)
推荐(0)
HDU 1005 Number Sequence
摘要:Problem Description A numbersequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you...
阅读全文
posted @
2015-04-24 10:28
星斗万千
阅读(122)
推荐(0)
HDU 1004 Let the Balloon Rise
摘要:Problem Description Contest timeagain! How excited it is to see balloons floating around. But to tell you asecret, the judges' favorite time is gues...
阅读全文
posted @
2015-04-24 10:28
星斗万千
阅读(113)
推荐(0)
UVA K Smallest Sums(多路归并,优先队列)
摘要:Description You're given k arrays, each array has k integers. There are kk ways to pick exactly one element in each array and calculate the sum of...
阅读全文
posted @
2015-04-23 10:33
星斗万千
阅读(326)
推荐(0)
POJ 2051 Argus(优先队列)
摘要:Description A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Internet traffic, financial ...
阅读全文
posted @
2015-04-23 10:09
星斗万千
阅读(164)
推荐(0)
RMQ算法
摘要:1. 概述 RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,jO(nlogn) { for(int j = 1; j using namespace std...
阅读全文
posted @
2015-04-21 15:30
星斗万千
阅读(180)
推荐(0)
UVA 11235 Frequent values (RMQ)
摘要:You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries consisting of...
阅读全文
posted @
2015-04-21 15:03
星斗万千
阅读(200)
推荐(0)
POJ 3928 Ping pong (树状数组)
摘要:Description N(3 #include #include #include using namespace std; struct node { int data,id; }p[20020]; int C[20020],n; bool cmp(node a,node b...
阅读全文
posted @
2015-04-21 13:54
星斗万千
阅读(127)
推荐(0)
2015编程之美 基站选址
摘要:描述 需要在一个N × M的网格中建立一个通讯基站,通讯基站仅必须建立在格点上。 网格中有A个用户,每个用户的通讯代价是用户到基站欧几里得距离的平方。 网格中还有B个通讯公司,维护基站的代价是基站到最近的一个通讯公司的路程(路程定义为曼哈顿距离)。 在网格中建立基站的总代价是用户通讯...
阅读全文
posted @
2015-04-20 19:42
星斗万千
阅读(203)
推荐(0)
2015编程之美 骨牌覆盖问题·二 (快速幂)
摘要:描述 上一周我们研究了2xN的骨牌问题,这一周我们不妨加大一下难度,研究一下3xN的骨牌问题? 所以我们的题目是:对于3xN的棋盘,使用1x2的骨牌去覆盖一共有多少种不同的覆盖方法呢? 首先我们可以肯定,奇数长度一定是没有办法覆盖的;对于偶数长度,比如2,4,我们有下面几种覆盖方式: 提...
阅读全文
posted @
2015-04-20 16:56
星斗万千
阅读(226)
推荐(0)
2015编程之美 回文字符序列(区间Dp)
摘要:给定字符串,求它的回文子序列个数。回文子序列反转字符顺序后仍然与原序列相同。例如字符串aba中,回文子序列为"a", "a", "aa", "b", "aba",共5个。内容相同位置不同的子序列算不同的子序列。 输入 第一行一个整数T,表示数据组数。之后是T组数据,每组数据为一行字符串。 ...
阅读全文
posted @
2015-04-18 14:35
星斗万千
阅读(196)
推荐(0)
2015编程之美 骨牌覆盖问题·一(矩阵快速幂)
摘要:描述 骨牌,一种古老的玩具。今天我们要研究的是骨牌的覆盖问题: 我们有一个2xN的长条形棋盘,然后用1x2的骨牌去覆盖整个棋盘。对于这个棋盘,一共有多少种不同的覆盖方法呢? 举个例子,对于长度为1到3的棋盘,我们有下面几种覆盖方式: 提示:骨牌覆盖 提示:如何快速计算结果 输入 第1行...
阅读全文
posted @
2015-04-18 14:17
星斗万千
阅读(222)
推荐(0)
UVA 11464 Even Parity(枚举)
摘要:Description We have a grid of size N x N. Each cell of the grid initially contains a zero(0) or a one(1). The parity of a cell is the number of 1s...
阅读全文
posted @
2015-04-18 09:40
星斗万千
阅读(113)
推荐(0)
2015 编程之美 2月29日
摘要:描述 给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期)。 只有闰年有2月29日,满足以下一个条件的年份为闰年: 1. 年份能被4整除但不能被100整除 2. 年份能被400整除 输入 第一行为一个整数T,表示数据组数。 之后每组数据包含两行。每一行格式为"month da...
阅读全文
posted @
2015-04-17 19:28
星斗万千
阅读(103)
推荐(0)
UVA 10881 Piotr's Ants
摘要:Piotr likes playing with ants. He has n of them on a horizontal pole L cm long. Each ant is facing either left or right and walks at a constant spee...
阅读全文
posted @
2015-04-17 17:27
星斗万千
阅读(116)
推荐(0)
UVA 11300 Spreading the Wealth
摘要:Problem A Communist regime is trying to redistribute wealth in a village. They have have decided to sit everyone around a circular table. First, ev...
阅读全文
posted @
2015-04-17 16:31
星斗万千
阅读(98)
推荐(0)
UVA 11729 Commando War(排序+贪心)
摘要:There is a war and it doesn't look very promising for your country. Now it's time to act. You have a commando squad at your disposal and planning an...
阅读全文
posted @
2015-04-17 11:58
星斗万千
阅读(126)
推荐(0)
UVA 11292 Dragon of Loowater(贪心+排序)
摘要:Description Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The ...
阅读全文
posted @
2015-04-17 11:14
星斗万千
阅读(125)
推荐(0)
STL之vector容器
摘要:介绍 这篇文章的目的是为了介绍std::vector,如何恰当地使用它们的成员函数等操作。本文中还讨论了条件函数和函数指针在迭代算法中使用,如在remove_if()和for_each()中的使用。通过阅读这篇文章读者应该能够有效地使用vector容器,而且应该不会再去使用C类型的动态数组了...
阅读全文
posted @
2015-04-13 20:04
星斗万千
阅读(127)
推荐(0)
浙大第15届校赛 3361 Valid Pattern Lock (搜索)
摘要:Pattern lock security is generally used in Android handsets instead of a password. The pattern lock can be set by joining points on a 3 × 3 matrix i...
阅读全文
posted @
2015-04-13 16:46
星斗万千
阅读(135)
推荐(0)
bestcoder Rikka with string
摘要:Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. Ther...
阅读全文
posted @
2015-04-11 21:05
星斗万千
阅读(137)
推荐(0)
STL系列之一 deque双向队列
摘要:deque双向队列是一种双向开口的连续线性空间,可以高效的在头尾两端插入和删除元素,deque在接口上和vector非常相似,下面列出deque的常用成员函数: deque的实现比较复杂,内部会维护一个map(注意!不是STL中的map容器)即一小块连续的空间,该空间中...
阅读全文
posted @
2015-04-11 21:03
星斗万千
阅读(179)
推荐(0)
蓝桥杯 角谷步数
摘要:你听说过角谷猜想吗? 任意的正整数,比如 5, 我们从它开始,如下规则计算: 如果是偶数,则除以2,如果是奇数,则乘以3再加1. 如此循环,最终必会得到“1” ! 比如 5 的处理过程是: 5 16 8 4 2 1 一个正整数经过多少步才能变成1, 称为角谷步数。 对于5而言,步数也是5 对于...
阅读全文
posted @
2015-04-10 10:26
星斗万千
阅读(254)
推荐(0)
蓝桥杯 砝码称重
摘要:5个砝码 用天平称重时,我们希望用尽可能少的砝码组合称出尽可能多的重量。 如果只有5个砝码,重量分别是1,3,9,27,81。则它们可以组合称出1到121之间任意整数重量(砝码允许放在左右两个盘中)。 本题目要求编程实现:对用户给定的重量,给出砝码组合方案。 例如: 用户输入: 5 程序输出:...
阅读全文
posted @
2015-04-09 11:21
星斗万千
阅读(498)
推荐(0)
蓝桥杯 制作表格
摘要:在中文Windows环境下,控制台窗口中也可以用特殊符号拼出漂亮的表格来。 比如: ┌─┬─┐ │ │ │ ├─┼─┤ │ │ | └─┴─┘ 其实,它是由如下的符号拼接的: 左上 = ┌ 上 = ┬ 右上 = ┐ 左 = ├ 中心 = ┼ 右 ...
阅读全文
posted @
2015-04-08 16:25
星斗万千
阅读(258)
推荐(0)
蓝桥杯 信用卡号检验
摘要:当你输入信用卡号码的时候,有没有担心输错了而造成损失呢?其实可以不必这么担心,因为并不是一个随便的信用卡号码都是合法的,它必须通过Luhn算法来验证通过。 该校验的过程: 1、从卡号最后一位数字开始,逆向将奇数位(1、3、5等等)相加。 2、从卡号最后一位数字开始,逆向将偶数位数字,先乘以2(如...
阅读全文
posted @
2015-04-08 15:31
星斗万千
阅读(177)
推荐(0)
蓝桥杯 有理数的循环节
摘要:1/7 = 0.142857142... 是个无限循环小数。 任何有理数都可以表示为无限循环小数的形式。 本题目要求即是:给出一个数字的循环小数表示法。 例如: 输入: 1,5 则输出: 0.2 输入: 1,7 则输出: 0.[142857] 输入: 7,6 则输出: 1.1[6] 用户输入的...
阅读全文
posted @
2015-04-08 15:27
星斗万千
阅读(379)
推荐(0)
蓝桥杯 三角螺旋阵
摘要:方阵的主对角线之上称为“上三角”。 请你设计一个用于填充n阶方阵的上三角区域的程序。填充的规则是:使用1,2,3….的自然数列,从左上角开始,按照顺时针方向螺旋填充。 例如:当n=3时,输出: 1 2 3 6 4 5 当n=4时,输出: 1 2 3 ...
阅读全文
posted @
2015-04-07 20:36
星斗万千
阅读(179)
推荐(0)
蓝桥杯 填写乘法算式
摘要:观察下面的算式: * * × * * = * * * 它表示:两个两位数字相乘,结果是3位数。其中的星号(*)代表任意的数字,可以相同,也可以不同,只要不是在首位的就可以是0。当然,满足这个要求的算式很多,但我们还有如下的要求: 所有星号所代表的数字全都是奇数。满足这个要求的算式就不多了。 比如...
阅读全文
posted @
2015-04-07 20:34
星斗万千
阅读(166)
推荐(0)
蓝桥杯 打印回型嵌套
摘要:*********** * * * ******* * * * * * * * *** * * * * * * * * * * *** * * * * * * * ******* * * * *********** 观察这个图形,它是由一系列正方形...
阅读全文
posted @
2015-04-07 20:23
星斗万千
阅读(163)
推荐(0)
蓝桥杯 串的处理
摘要:串的处理 在实际的开发工作中,对字符串的处理是最常见的编程任务。本题目即是要求程序对用户输入的串进行处理。具体规则如下: 1. 把每个单词的首字母变为大写。 2. 把数字与字母之间用下划线字符(_)分开,使得更清晰 3. 把单词中间有多个空格的调整为1个空格。 例如: 用户输入: you an...
阅读全文
posted @
2015-04-07 20:03
星斗万千
阅读(248)
推荐(0)
蓝桥杯 猜算式
摘要:看下面的算式: □□ x □□ = □□ x □□□ 它表示:两个两位数相乘等于一个两位数乘以一个三位数。 如果没有限定条件,这样的例子很多。 但目前的限定是:这9个方块,表示1~9的9个数字,不包含0。 该算式中1至9的每个数字出现且只出现一次! 比如: 46 x 79 = 23 x 158 ...
阅读全文
posted @
2015-04-07 18:58
星斗万千
阅读(254)
推荐(0)
蓝桥杯 地址转换
摘要:Excel是最常用的办公软件。每个单元格都有唯一的地址表示。比如:第12行第4列表示为:“D12”,第5行第255列表示为“IU5”。 事实上,Excel提供了两种地址表示方法,还有一种表示法叫做RC格式地址。 第12行第4列表示为:“R12C4”,第5行第255列表示为“R5C255”。 ...
阅读全文
posted @
2015-04-07 18:03
星斗万千
阅读(159)
推荐(0)
蓝桥杯 花朵数
摘要:一个N位的十进制正整数,如果它的每个位上的数字的N次方的和等于这个数本身,则称其为花朵数。 例如: 当N=3时,153就满足条件,因为 1^3 + 5^3 + 3^3 = 153,这样的数字也被称为水仙花数(其中,“^”表示乘方,5^3表示5的3次方,也就是立方)。 当N=4时,1634满足条件...
阅读全文
posted @
2015-04-07 18:00
星斗万千
阅读(392)
推荐(0)
新龟兔赛跑
摘要:Description 大家还记得龟兔赛跑的故事吗?兔子输给了乌龟,但是他一直都不服气,想要一雪前耻。他把他的族人全部都带来了海边,要与乌龟一族一比高下。嚣张的兔子们,给了乌龟一个月的时间来准备这场”世纪大战”。如临大敌的乌龟们每天没日没夜的锻炼,在高帅富Bearboy的帮助下,乌龟的速度再也...
阅读全文
posted @
2015-04-03 17:40
星斗万千
阅读(261)
推荐(0)
Doorman
摘要:Description The doorman Bruno at the popular night club Heaven is having a hard time fulfilling his duties. He was told by the owner that when the...
阅读全文
posted @
2015-04-03 16:54
星斗万千
阅读(354)
推荐(0)
计算球的位置(水题)
摘要:Description 丁小辉准备参加YT大学首届斯诺克比赛,但是他发现自己击中目标有问题。教练说:你必须在任何时刻知道球的位置,而球的位置是由击球的速度和时间决定的。那么,给定初始位置和初始速度,经过 t 时间后,球会落到台面的哪个点呢? 为简单起见,假定台面是一个矩形,矩形的左上角坐标是 ...
阅读全文
posted @
2015-04-03 16:44
星斗万千
阅读(260)
推荐(0)
军训 (水题)
摘要:Description 有N 个军训新学员开始了他们的军训生活,第一天教官教他们站队,根据他们的身高,站成“凸”字形或者“凹”字形,也就是从左到右身高依次递增再递减或者依次递减再递增,如果是“凸”字形队列,身高最高的人可以有一个或者多个,其他人必须严格递增或或者递减,同样地,如果是“凹”字形...
阅读全文
posted @
2015-04-03 16:13
星斗万千
阅读(254)
推荐(0)