- 博客(74)
- 收藏
- 关注
原创 Play on Words
Play on Words要点:先判断是否存在欧拉路,在判断是否连通;代码:#include #include #include using namespace std;int vis[26][26], in[26], out[26], temp[26];void dfs(int y){ temp[y] = 1; for (int j = 0; j < 2
2015-09-07 20:06:54
287
原创 Bicoloring
Bicoloring代码:#include #include #include using namespace std;int path[205][205];int vis[205], m, n;bool col[205];bool bfs(){ queue que; que.push(0); vis[0] = 1; col[0] = true; while
2015-09-07 14:50:16
265
原创 The Monocycle
The Monocycle大意:有一辆独轮车在广场上运动,开始时方向朝北,轮子接触地面的颜色为绿色,车子每向前走一格耗时1秒,拐弯耗时1秒;车子轮胎由5种颜色组成;求出一条耗时最短的路线,到达终点时,使得车子接触地面的也为绿色,方向无所谓;要点:判断车子是否可以走的标记数组应由传统的vis[x][y]转变成vis[x][y][dir][col],即判断坐标时也要考虑
2015-08-28 16:39:49
421
原创 XYZZY
XYZZY大意:模拟一个游戏,初始时有100能量,处于房间1, 现在输入n,表示有n个房间的信息,接下来n行,每行输入进入房间n的所获得的能量,以及该房间可以进入其他房间的数目;房间可以重复进入,求出能否到达房间n,且到达每个房间时能量都大于0;要点:房间可以重复进入,所以能量可以达到无限;可以判断每次到达某个房间时的能量,下一次到达该房间时如果能量大于上一次的能量
2015-08-28 10:55:41
833
原创 Dungeon Master
Dungeon MasterDescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one
2015-08-24 19:51:27
807
原创 Knight Moves
Knight MovesDescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a g
2015-08-23 14:49:16
257
原创 Slash Maze
Slash MazeDescriptionBy filling a rectangle with slashes (/) and backslashes ( ), you can generate nice little mazes. Here is an example: As you can see, paths in the maze cannot b
2015-08-23 09:23:15
297
原创 Maze Exploration
Maze Exploration大意:给出一张图,图上有一点*,以此处向外围运动(上下左右),将能到达的位置标记为#(包括最初的位置);要点:用dfs模拟即可:代码:#include #include using namespace std;int dir[4][2] = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 }
2015-08-21 20:17:41
333
原创 The die is cast
The die is castDescriptionInterGames is a high-tech startup company that specializes in developing technology that allows users to play games over the Internet. A market analysis has alert
2015-08-21 19:36:25
553
原创 Oil Deposits
Oil DepositsDescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time,
2015-08-21 15:48:25
253
原创 Undraw the Trees
Undraw the Trees大意:由一张图求出该树的先序遍历;要点:节点的字符可能是任意的ASCII字符但不包括'|','-' ,' ';可以由|知道该节点是否有左右分支;代码:#include #include #include #include using namespace std;string str[205];void bfs(int be
2015-08-21 10:34:15
289
原创 Not so Mobile
Not so MobileDescriptionBefore being an ubiquous communications gadget, a mobile was just a structure made of strings and wires suspending colourfull things. This kind of mobile is usually
2015-08-20 21:16:29
272
原创 Evaluating Simple C Expressions
Evaluating Simple C ExpressionsDescriptionThe task in this problem is to evaluate a sequence of simple C expressions, buy you need not know C to solve the problem! Each of the expressions
2015-08-20 19:32:47
364
原创 The Falling Leaves
The Falling LeavesDescriptionEach year, fall in the North Central region is accompanied by the brilliant colors of the leaves on the trees, followed quickly by the falling leaves accumulating
2015-08-20 15:21:12
265
原创 S-Trees
S-TreesDescriptionA Strange Tree (S-tree) over the variable set is a binary tree representing a Boolean function . Each path of the S-tree begins at theroot node and consists of n+1 n
2015-08-19 20:54:56
293
原创 Quadtrees
QuadtreesDescriptionA quadtree is a representation format used to encode images. The fundamental idea behind the quadtree is that any image can be split into four quadrants. Each quadrant
2015-08-19 16:16:52
236
原创 Tree Summing
Tree SummingAppoint description:DescriptionBackgroundLISP was one of the earliest high-level programming languages and, with FORTRAN, is one of the oldest languages currently being use
2015-08-18 16:04:58
398
原创 Hartals
Hartals大意:给出组数据T代表测试样例数,N代表天数,P代表团队个数,接着给出P个团队的罢工周期;时间从星期天开始,如果遇到多个团队同一天罢工则算罢工一天,如果遇到星期五,星期六则算休息,不算罢工;求出N天中,罢工了多少天;要点:模拟一下即可;代码:#include int main(){ int t; scanf ("%d", &t); getch
2015-08-18 11:30:42
329
原创 Team Queue
Team QueueDescriptionQueues and Priority Queues are data structures which are known to most computer scientists. TheTeam Queue, however, is not so well known, though it occurs often in eve
2015-08-18 10:22:57
279
原创 Expressions
Expressions大意:貌似是栈可以用来模拟后缀运算符的运算方式,而队列可以用来模拟中缀运算符的运算方式,小写字母代表数字,大写字母代表运算符;如例1 xyPzwIM 栈下模拟运算为 (wIz)M(yPx)wzyxIPM 队列模拟运算为 (wIz)M(yPx)给出栈下的字符串,求出和栈下运算结果相同的队列字符串;要点:可以建立二叉树,遇到小写字母则压入。遇到
2015-08-17 20:06:52
293
原创 Generalized Matrioshkas
Generalized Matrioshkas大意:给出一组数据如-9,-7,-2,2,-3,-1,-2,2,1,3, 7, 9,其中一对相反数如-9,9为一个娃娃的尺寸,9尺寸的娃娃中套着2尺寸和3尺寸的娃娃,3尺寸的娃娃中又套着1尺寸的娃娃,1尺寸的娃娃套着2尺寸的娃娃,因为相邻内部的娃娃尺寸之和不能大于或等于相邻的外部娃娃的尺寸,2>1,输出TRY AGAIN要点:使用两
2015-08-17 14:50:14
558
原创 Matrix Chain Multiplication
#include #include struct let{ char name; int x; int y;};int main(){ struct let x[100]; int num; scanf ("%d", &num); getchar(); int u = 0; while (num--){ scanf ("%c%d%d", &x[u].name, &
2015-08-11 18:52:28
212
原创 ShellSort
ShellSort大意:给出N乌龟的名字,再给出这些名字的排序;每次只能将一只乌龟放到最顶端,求最少的挪移个数;要点:第一个被动的乌龟肯定在所有被动的乌龟的最下方,所以从下往上找第一个被动过的乌龟;代码:#include #include #include int main(){ int n; scanf ("%d", &n); getchar(); w
2015-08-11 15:17:35
300
原创 Parentheses Balance
Parentheses BalanceDescriptionYou are given a string consisting of parentheses () and []. A string of this type is said to becorrect: (a) if it is the empty string (b) if A and B are c
2015-08-11 11:42:41
400
原创 The Blocks Problem
The Blocks ProblemDescriptionBackground Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and
2015-08-08 10:35:48
262
原创 "Accordian" Patience
"Accordian" PatienceDescriptionYou are to simulate the playing of games of ``Accordian'' patience, the rules for which are as follows:Deal cards one by one in a row from left to righ
2015-08-07 22:15:32
755
原创 Myacm Triangles
#include #include using namespace std;struct point{ char name; int x; int y;}p[20];struct tri{ point pp[3]; double s;}triang[10000];int cmp(tri a, tri b){ return a.s > b.s;}int
2015-08-07 16:33:44
500
原创 Billiard
Billiard大意:给出一个桌子垂直边为b, 水平边为a,一个球刚开始与水平有一夹角,在s秒内,与水平边碰撞n次,垂直边碰撞m次 ;求出小球的角速度和线速度;要点:在垂直方向,和水平方向分别求出速度,和角度;代码:#include #include int main(){ double a, b, s, m, n; while (scanf ("%lf %l
2015-08-07 10:55:27
495
原创 Inscribed Circles and Isosceles Triangles
Inscribed Circles and Isosceles TrianglesDescriptionGiven two real numbers Bthe width of the base of an isosceles triangle in inches Hthe altitude of the same isosceles triangle in inche
2015-08-07 09:48:59
261
原创 Clock Hands
Clock HandsDescriptionThe medieval interest in mechanical contrivances is well illustrated by the development of the mechanical clock, the oldest of which is driven by weights and controlled
2015-08-06 19:58:39
430
原创 The Other Two Trees
The Other Two Trees大意:给出一组对角线坐标,求出正方形另外一组对角线坐标;要点:可将问题转化为坐标旋转问题;设旋转前的坐标为x1,y1,旋转中心为x,y,旋转角度为t,旋转后坐标为x2, y2;x2 = (x1 - x)*cos(t) - (y1 - y) * sin(t) + x;y2 = (x1 - x)*sin(t) + (x1 - y) *
2015-08-06 19:04:15
261
原创 Code Refactoring
Code Refactoring大意:将所给的数分解为两个因数相乘,求出两两不相同的两组, 1和自身不可以;代码:#include int main(){ int alltext; scanf ("%d", &alltext); getchar(); int count = 1; while (alltext--){ int k; scanf ("%d", &
2015-08-06 16:33:32
280
原创 Factoring Large Numbers
Factoring Large Numbers大意:将一个数转化为质数相乘的形式;即求出所给数的所有分解至最小的因数;代码:#include using namespace std;int main(){ long long num; while (cin >> num && num > 0){ for (long long i = 2; i <= num &
2015-08-06 15:50:53
307
原创 How many zero's and how many digits ?
How many zero's and how many digits ?大意:给出一个数字N和进制B,求N!在B进制下,有多少个尾0,有多少位数字;代码:#include #include #include int flag[1000];int main(){ int n, b; while (scanf ("%d %d", &n, &b) != EOF){
2015-08-06 14:41:34
244
原创 Pseudo-Random Numbers
Pseudo-Random NumbersDescriptionComputers normally cannot generate really random numbers, but frequently are used to generate sequences of pseudo-random numbers. These are generated by some al
2015-08-06 09:25:15
207
原创 Uniform Generator
Uniform GeneratorDescriptionComputer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the formwhere `` " is the modulus operator.
2015-08-06 08:42:18
242
原创 Just the Facts
Just the FactsDescription The expression N!, read as `` N factorial," denotes the product of the firstN positive integers, where N is nonnegative. So, for example,NN!01
2015-08-05 19:02:51
215
原创 Multiplying by Rotation
Multiplying by Rotation大意:有一些数字的乘法计算很奇特,如179487*4=717948;即把最后一位提到最前面;现在给出n1,n2,n3,n1代表计算是的进制,n2代表第一个乘数的最后以为,n3代表第三个乘数,求出n2的长度;要点:以179487*4=717948为例,由于.....7*4=7.....;4×7 = 28,得出右数第1个数为8,
2015-08-05 16:01:04
428
原创 Light, more light
Light, more light大意:一个人对走廊上的N盏灯进行开关灯,总共走过了N次,每走完一次便会回到起点;开关灯的规则为当他第i次走过一盏灯时,如果该灯的编号能够被i整除,便把灯开或关一次;开始时所有的灯为关闭,求出最后一盏灯的开关状态;要点:该题目求得是一个数N它具有几个因数;除了1和它本身外可能还有其他因数,但是只有当N的被开方数为整数时,N的因数为奇数个,
2015-08-05 14:50:43
247
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人