- 博客(33)
- 收藏
- 关注
原创 Codeforces Round #306 (Div. 2) A
A. Two Substringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given string s. Your task is to d
2015-06-05 21:16:58
700
原创 Codeforces Round #304 (Div. 2) D Soldier and Number Game
D. Soldier and Number Gametime limit per test 3 secondsmemory limit per test 256 megabytesinput standard inputoutput standard outputTwo soldiers are playing a g
2015-05-30 20:59:32
871
原创 Codeforces Round #304 (Div. 2) C Soldier and Cards
C. Soldier and Cardstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo bored soldiers are playing card wa
2015-05-30 20:53:12
554
原创 Codeforces Round #304 (Div. 2) B
B. Soldier and Badgestime limit per test 3 seconds memory limit per test 256 megabytesinput standard input output standard outputColonel has n badges. He wants to give one b
2015-05-30 20:48:57
578
原创 FZU 1890 竞技游戏 水
B - 竞技游戏DescriptionJohn和Smith在玩一种竞技游戏。在游戏中,John给Smith由n个正整数组成的序列以及m条操作指令,需要Smith按照指令来对n个整数进行操作。其中每条指令都包括二个整数(a, b),意义如下: 如果a大于0,表示将序列中第b个数乘于2; 如果a小于0,表示将序列中第b个数加上2; 如果a等于0,则忽略此条指
2015-05-16 21:23:55
907
原创 FZU 1889 水
A - 龟兔赛跑Description万众瞩目的第七届龟兔赛跑比赛在北京时间3333年3月3日于火星打响。此次龟兔赛跑比赛的规则与往届有所不同,不再考察兔子和乌龟谁在最短的时间内跑完规定的路程,而是考察谁在规定时间内跑的路程最长,而且兔子和乌龟在跑步都是匀速的。由于兔子的坏习惯,它总是喜欢把比赛的总时间T小时中的K小时拿来睡觉。现在给你比赛总时间T、兔子睡觉时间K、兔子的时速U、乌龟的
2015-05-16 21:18:31
1155
原创 FZU 1893 内存管理
E - 内存管理Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescription在为进程动态分配内存时,操作系统必须对其进行管理。一种管理内存的方式是,维护一张记录内存使用情况的表来模拟内存的存储情况,其任一表项可能是以下两种情况之一:一个已分配给进
2015-05-16 21:08:56
707
原创 FZU 1894 志愿者选拔
F - 志愿者选拔Description世博会马上就要开幕了,福州大学组织了一次志愿者选拔活动。 参加志愿者选拔的同学们排队接受面试官们的面试。参加面试的同学们按照先来先面试并且先结束的原则接受面试官们的考查。 面试中每个人的人品是主要考查对象之一。(提高人品的方法有扶老奶奶过街,不闯红灯等) 作为主面试官的John想知道当前正在接受面试的同学队伍中人品
2015-05-16 20:58:25
733
原创 UVALive 2963 Hypertransmission
2963 - HypertransmissionTime limit: 6.000 secondsDescriptionThe president of the Galactic Federation has recently decided that all planets of the galaxy must establish hyper-radio centers to b
2015-05-10 09:54:04
998
原创 UVA10635 Prince and Princess(LIS)
题意:王子和公主同时从1出发走到 n*n, 求他们两个路径的最长公共子序列;思路:因为这题n有250,如果用LCS负责度为O(n^2),容易超时,于是我们选择它的优化版Lis算法来求最长公共子序列,这样我们的复杂度就降为O(n*logn)了。Lis算法: 先回顾经典的O(n^2)的动态规划算法,设A[t]表示序列中的第t个数,F[t]表示从1到t这一段中以t结尾的最长上升子序列
2015-05-07 20:42:43
921
原创 UVA11174 J.Stand in a Line (计数+逆元)
题意:n个人排队,m条父子关系,要求父亲一定要排在儿子前面(不一定要相邻),问最多能有多少种排法?思路:父亲一定要排在儿子前面,也就是说父亲和儿子的位置是不可以调换的,那么我们不妨把父亲和儿子看成是同一个数字,例如2是4和5的父亲,3是6的父亲,那么我们不妨把这5个人看成是22233在排队,那么总共的排法就是5!/(3!*2!);要注意的是每个平行的父亲之间,他们的子树是符合乘法原理的,对
2015-05-06 20:38:34
822
原创 HDU 4565 so easy(矩阵快速幂)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4565代码如下:#include #include #include #include #include using namespace std;#define LL __int64struct matrix{LL f[2][2];};LL m;mat
2015-05-05 21:48:15
729
原创 福州大学第十二届程序设计竞赛 B.完美的数字
Problem B 完美的数字Time Limit: 1000 mSec Memory Limit : 32768 KB Problem DescriptionBob是个很喜欢数字的孩子,现在他正在研究一个与数字相关的题目,我们知道一个数字的完美度是 把这个数字分解成三个整数相乘A*A*B(0S,S表示的是从a到b的所有数字的流行度之和,即S=d(a)+d
2015-05-03 16:41:34
1380
原创 codeforces 7D Palindrome Degree
题目链接:http://codeforces.com/problemset/problem/7/D题意:(1)任何串(包括空串)都是0-回文;(2)一个长度为n的回文串,若它的前n/2个字符和后n/2个字符都是(k-1)-回文,则它是k-回文。现给定一个串,设它的前缀分别是x-回文,求所有这些x值的和。比如: abacaba前缀 xa
2015-05-02 22:55:31
1088
1
原创 codeforces535D:Tavas and Nafas
Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants t
2015-04-27 20:08:51
801
原创 ZOJ 3876 May Day Holiday
May Day HolidayTime Limit: 2 Seconds Memory Limit: 65536 KB As a university advocating self-learning and work-rest balance, Marjar University has so many days of rest, including hol
2015-04-26 17:26:56
675
原创 ZOJ 3878 Convert QWERTY to Dvorak(12th 浙江省赛)
Convert QWERTY to DvorakTime Limit: 2 Seconds Memory Limit: 65536 KBEdward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY Keyboard with a broken Caps
2015-04-26 11:27:34
1546
原创 ZOJ 3865 Superbot(BFS)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3865题意:给你一个n*m的地图,求出从@走到$的最小时间.使用按钮去控制机器人走的方向;四个按钮的初始位置是:左右上下,每隔P秒按钮就会向右移动,变成:下左右上、上下左右、右上下左……思路:为了简化按钮的移动步骤,我们直接用二进制给四个位置标记,1
2015-04-18 22:02:13
661
原创 CodeForces 514D R2D2 and Droid Army
D. R2D2 and Droid ArmyAn army of n droids is lined up in one row. Each droid is described by m integers a1, a2, ..., am, where ai is the number of details of thei-th type in this droid's m
2015-04-16 22:32:31
950
原创 HDU4267 A Simple Problem with Integers
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4267题意:题目中有两种操作1.每隔k点更新;2.查询最底层的叶子节点的值;思路:因为k不是固定的,但是k的范围又很小,只有1-10,所以我们不妨在每个区域都开一个数组来标记不同的k,代表从最左端的那个点开始,在此区域内,每隔k个点都是有效点。要注意的是,每个区域的起始位置的那个点一定要
2015-04-16 22:25:01
771
原创 浙大第十五届校赛 G-Cylinder Candy
Cylinder CandyTime Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Edward the confectioner is making a new batch of chocolate covered candy. Each candy center is shaped as a
2015-04-14 10:54:57
1536
原创 湖南多校对抗赛3.28 J - Jerry's trouble
Problem J: Jerry's troubleTime Limit: 10 Sec Memory Limit: 256 MBSubmit: 96 Solved: 46[Submit][Status][Web Board]Description Jerry is caught by Tom. He was penned up in one room with a
2015-04-05 16:49:59
1135
原创 湖南多校对抗赛3.28 D Simple String
Problem D: Simple StringTime Limit: 1 Sec Memory Limit: 256 MBSubmit: 74 Solved: 35[Submit][Status][Web Board]DescriptionWelcome,this is the 2015 3th Multiple Universities Programming
2015-04-05 16:23:33
858
原创 HDU3681 Prison Break(壮压dp+二分+bfs)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3681题意:一个机器人想越狱,他只能带一定电量的电池,'S'表示道路可行,'G'表示充电器(充满),只可充电一次,但是可以经过很多次。'F'表示起点,'Y'表示要破坏的机关,也是只需破坏一次,但是可以经过无数次。'D'表示不能经过的地点。求他能破坏所有机关,带的最小初始电量。思路:既然我们要破坏
2015-03-24 18:52:46
913
原创 URAL-1329 Galactic History
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1329题意:给你一个N,接下来有N行数,每行有两个数a,b, 其中b是a是父节点,如果b的父节点是-1,那么b就是所有数的根。然后再输入一个L,接下来有L行数,每行有两个数p,q, 如果p是q的父节点,输出1,如果q是p的父节点, 就输出2,如果都不是,输出0。思路:一开始想用parent
2015-03-22 22:13:03
767
原创 HDU 1074 Doing Homework(壮压 dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1074题意:有n个作业要做,每个作业都有deadline 和 做该项作业需要花费的时间,合理安排做作业的顺序,使得超额天数最小,输出该天数,并输出做作业的顺序。思路:每样作业有完成和未完成两种状态,很显然这是一道状态压缩dp,这也是我做的第一道壮压(回想起来都是辛酸史啊……)壮压一般考验的都是我
2015-03-21 20:27:34
772
原创 POJ 2370 Democracy in Danger
题目链接:http://poj.org/problem?id=2370题意:有k组人投票,赞成组数超过一半或者赞成人数超过一半,满足2种情况中的一种就可实施。题目意思弄清楚了这题就很水了。代码如下:#include#include#include#includeusing namespace std;int k;int a[110];int dp[110][110]
2015-03-21 20:19:26
689
原创 POJ 2366 (URAL 1021)Sacrament of the Sum
题目链接:http://poj.org/problem?id=2366#include#includeconst int maxn=1e6+10;int a[maxn];int b[maxn];int m,n,x;int main(){ memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); scanf("%d", &n); fo
2015-03-21 19:52:51
793
原创 POJ1651:Multiplication Puzzle(简单dp)题解
Multiplication PuzzleDescriptionThe multiplication puzzle is played with a row of cards, each containing a single positive integer. During the move player takes one card out of the row and sco
2015-03-16 10:18:50
805
原创 URAL1826 Minefield(简单递归)
MinefieldDescriptionTo fulfill an assignment, a reconnaissance group of n people must cross the enemy's minefield. Since the group has only one mine detector, the following course of action
2015-03-15 17:28:47
885
原创 foj 2173 nostop
G - NostopDescriptionM国有N个城市,H条单向的道路,AekdyCoin从编号为1的城市出发,每经过一条道路要花一个单位的时间。假设他出发的时刻为0,他需要在K时刻到达编号为N的城市。并且,AekdyCoin不会在一个城市停留,每到一个城市他要立刻往下一个城市出发,最后在K时刻时他必须在城市N。虽然AekdyCoin经过任意一条道路的花费的时间都是1
2015-03-14 23:25:02
655
原创 CodeForces 238C World Eater Brothers(tree dp)
DescriptionCodeForces 238C World Eater Brothers(tree dp) You must have heard of the two brothers dreaming of ruling the world. With all their previous plans failed, this time they decided to cooperate with each other in order to rule the world.
2015-03-14 21:17:53
909
转载 函数的参数和函数调用
1 函数的参数在调用函数时,大多数情况下主调函数和被调函数之间存在着数据传递关系。于是就用到了形式参数和实际参数,简称形参和实参。在定义函数时函数名后面括号中的变量称为“形参”,在主调函数(一般为Main)调用一个函数时,函数名后面括号中的参数(可以是一个表达式)称为“实参”。例如:void func(int x,int y){.....}/
2015-03-14 16:07:06
4783
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅