自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 初级篇——穷竭搜索——广度优先搜索 aoj 0121 seven puzzle

7 puzzlesThe 7-puzzle consists of eight square cards and a frame that fits these cards snugly. Each card is numbered 0, 1, 2, …, 7 to distinguish them from each other. You can stack two cards vertica...

2020-04-21 20:30:39 178

原创 初级篇——穷竭搜索——深度优先搜索 poj3009Curling 2.0

DescriptionOn Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square ...

2020-04-21 14:13:28 162

原创 百练#1088滑雪 dp递归 +递推

题目略先上WA代码:#include<iostream>#include<cstdio>#include<cstring>using namespace std;const int MAX = 110;const int step[4][2] = {{0,-1},{-1,0},{0,1},{1,0}};int r,c,res,d[MAX][MAX...

2020-03-20 21:34:25 175

原创 百练#4119复杂的整数划分

描述将正整数n 表示成一系列正整数之和,n=n1+n2+…+nk, 其中n1>=n2>=…>=nk>=1 ,k>=1 。正整数n 的这种表示称为正整数n 的划分。输入标准的输入包含若干组测试数据。每组测试数据是一行输入数据,包括两个整数N 和 K。(0 < N <= 50, 0 < K <= N)输出对于每组测试数据,输出以下三行...

2020-03-18 16:08:56 426

原创 百练#2373Dividing the Path

描述Farmer John’s cows have discovered that the clover growing along the ridge of the hill in his field is particularly good. To keep the clover watered, Farmer John is installing water sprinklers alon...

2020-03-16 21:23:20 198

原创 spoj#GCJ1C09C - Bribe the Prisoners

ProblemIn a kingdom there are prison cells (numbered 1 to P) built to form a straight line segment. Cells number i and i+1 are adjacent, and prisoners in adjacent cells are called “neighbours.” A wal...

2020-03-15 20:54:20 131

原创 poj#3723Conscription

DescriptionWindy has a country, and he wants to build an army to protect his country. He has picked up N girls and M boys and wants to collect them to be his soldiers. To collect a soldier without an...

2020-03-13 18:46:43 143

原创 poj#3255Roadblocks

DescriptionBessie has moved to a small farm and sometimes enjoys returning to visit one of her best friends. She does not want to get to her old home too quickly, because she likes the scenery along ...

2020-03-13 15:10:17 116

转载 Floyd为什么是动态规划?

突然想到这个问题,死记硬背是没用滴,码一篇别人的博客。https://www.cnblogs.com/chenying99/p/3932877.html

2020-03-12 22:18:16 389

原创 百练#1182食物链

描述:略#include<iostream>using namespace std;const int MAX = 50010 * 3;int par[MAX],Rank[MAX];int find(int x){ if(x == par[x]) return x; return par[x] = find(par[x]);}void unite(int x,i...

2020-03-12 15:58:22 100

原创 百练#2431:Expedition

描述:略。#include<iostream>#include<queue>#include<algorithm>using namespace std;struct stop{ int pos,fuel; bool operator < (const stop& rhs)const{ return this -> pos...

2020-03-11 20:47:54 84

原创 百练#1191棋盘分割

描述:略(图太多懒得复制)思路来自https://blog.csdn.net/qq_40774175/article/details/82704582那个截图分析的很细致啊。#include<iostream>#include<cstring>#include<cmath>using namespace std;const int INF = 1...

2020-03-10 14:03:27 113

原创 百练#2803碎纸机

描述你现在负责设计一种新式的碎纸机。一般的碎纸机会把纸切成小片,变得难以阅读。而你设计的新式的碎纸机有以下的特点:1.每次切割之前,先要给定碎纸机一个目标数,而且在每张被送入碎纸机的纸片上也需要包含一个数。2.碎纸机切出的每个纸片上都包括一个数。3.要求切出的每个纸片上的数的和要不大于目标数而且与目标数最接近。举一个例子,如下图,假设目标数是50,输入纸片上的数是12346。碎纸机会把纸...

2020-03-09 21:50:37 241

原创 一道选择题引发的关于NAT的一点思考。

写在前面:此题为2019年北大801回忆版网络部分的一道选择题,当初复习时困扰我许久,如果题目没有问题的话,我想给出一点儿自己的拙见,因为没有答案,所以欢迎讨论。关于NAT协议,下列说法正确的是A. NAT可用于给内网主机分配IPB. 与外界通信时NAT可以作为内网主机的代理服务器C.可作为域名服务器D.可作为本地网关主要是BD两项,严伟老师等翻译的计算机网络第五版,指出网关是路由器的...

2020-03-08 16:48:42 255

原创 UVA#1220Party at Hali-Bula

描述:类似于最大独立集,略。#include<iostream>#include<string>#include<vector>#include<map>using namespace std;const int MAX = 210;int n,num,d[MAX][2],f[MAX][2];vector<int> su...

2020-03-07 21:15:58 85

原创 UVA#12186Another Crisis

描述:略#include<iostream>#include<vector>#include<algorithm>using namespace std;const int MAX = 100010;int T;vector<int> sub[MAX];//某个员工的直接下属 int dp(int p){ if(sub[p].em...

2020-03-07 15:41:32 85

原创 UVA#11584Partitioning by Palindromes

描述切割回文#include<iostream>#include<cstring>using namespace std;const int INF = 10000;int d[1005];int ispa[1005][1005],vis[1005][1005];char a[1010];int l;//int ispan(int s,int e){//...

2020-03-06 09:52:18 106

原创 UVA12563劲歌金曲

描述:略#include<iostream>#include<cstring>#include<algorithm>using namespace std;int song[55],d[55][180 * 50 + 678];//前i首歌,刚好是j秒的最多歌数,这样就和01背包一样啦。int main(){ //freopen("d://poj/...

2020-03-05 15:43:40 131

原创 UVA#1025A Spy in the Metro

描述略#include<iostream>#include<cstring>#include<algorithm>using namespace std;int d[205][55];//时刻i在车站j,至少等多久int train[205][55][2];//时刻i在车站j,是否有车int tp[55];//车站间隔const int INF ...

2020-03-03 22:32:54 102

原创 计蒜客#T1408矩形嵌套

有 nn 个矩形,每个矩形可以用 a,ba,b 来描述,表示长和宽。矩形 X(a,b)X(a,b) 可以嵌套在矩形 Y(c,d)Y(c,d) 中当且仅当 a <c,b<da<c,b<d 或者 b<c,a<db<c,a<d(相当于旋转 9090 度)。例如(1,51,5)可以嵌套在(6,26,2)内,但不能嵌套在(3,43,4)中。你的任务是选出尽可能...

2020-03-03 14:35:56 250

原创 UVA#10603Fill

倒水问题Sample Input22 3 4 296 97 199 62Sample Output2 29859 62#include<iostream>#include<cstring>#include<queue>#include<algorithm>using namespace std;const int M...

2020-02-28 16:48:58 73

原创 百练#1077Eight(hash实例)

描述八数码问题,目标固定为123456780,输出路径。输入You will receive a description of a configuration of the 8 puzzle. The description is just a list of the tiles in their initial positions, with the rows listed from to...

2020-02-28 14:18:44 192

原创 UVA-140 Bandwidth

带宽Sample InputA:FB;B:GC;D:GC;F:AGH;E:HD#Sample OutputA B C F G D H E -> 3#include<cstdio>#include<iostream>#include<vector>#include<string>#include<cstring&...

2020-02-27 17:06:20 118

原创 uva#129Krypton Factor

困难的串Sample Input7 330 30 0Sample OutputABAC ABA7ABAC ABCA CBAB CABA CABC ACBA CABA28#include<iostream>using namespace std;int n,l,cnt;int s[80];int dfs(int cur){ int i,j,k,ok; if...

2020-02-27 11:05:46 60

原创 uva#524Prime Ring

素数环A ring is composed of n (even number) circles as shown in diagram.Put natural numbers 1, 2, . . . , n into each circle separately, and thesum of numbers in two adjacent circles should be a prime...

2020-02-26 15:37:21 74

原创 poj#3253Fence Repair

DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer length...

2020-02-24 15:45:42 60

原创 UVA#12096The SetStack Computer

• PUSH will push the empty set {} on the stack.• DUP will duplicate the topmost set (pop the stack, and then push that set on the stack twice).• UNION will pop the stack twice and then push the unio...

2020-02-21 14:11:33 91

原创 百练#3752走迷宫

描述一个迷宫由R行C列格子组成,有的格子里有障碍物,不能走;有的格子是空地,可以走。给定一个迷宫,求从左上角走到右下角最少需要走多少步(数据保证一定能走到)。只能在水平方向或垂直方向走,不能斜着走。输入第一行是两个整数,R和C,代表迷宫的长和宽。( 1<= R,C <= 40)接下来是R行,每行C个字符,代表整个迷宫。空地格子用’.‘表示,有障碍物的格子用’#‘表示。迷宫...

2020-02-18 14:55:04 188

原创 百练#1852Ants

描述An army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. When a walking ant reaches an end of the pole, it immediatelly falls off it. When two ants meet they ...

2020-02-18 11:18:29 88

原创 百练#2802小游戏

描述一天早上,你起床的时候想:“我编程序这么牛,为什么不能靠这个赚点小钱呢?”因此你决定编写一个小游戏。游戏在一个分割成w * h个正方格子的矩形板上进行。如图所示,每个正方格子上可以有一张游戏卡片,当然也可以没有。当下面的情况满足时,我们认为两个游戏卡片之间有一条路径相连:路径只包含水平或者竖直的直线段。路径不能穿过别的游戏卡片。但是允许路径临时的离开矩形板。下面是一个例子:这里在 ...

2020-02-17 15:56:42 1178 1

原创 百练#2775文件结构图

描述在计算机上看到文件系统的结构通常很有用。Microsoft Windows上面的"explorer"程序就是这样的一个例子。但是在有图形界面之前,没有图形化的表示方法的,那时候最好的方式是把目录和文件的结构显示成一个"图"的样子,而且使用缩排的形式来表示目录的结构。比如:ROOT| dir1| file1| file2| file3| di...

2020-02-16 16:44:31 571

原创 百练#1011sticks

描述George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he had o...

2020-02-15 15:40:50 155

原创 百练#2754八后问题

描述会下国际象棋的人都很清楚:皇后可以在横、竖、斜线上不限步数地吃掉其他棋子。如何将8个皇后放在棋盘上(有8 * 8个方格),使它们谁也不能被吃掉!这就是著名的八皇后问题。对于某个满足要求的8皇后的摆放方法,定义一个皇后串a与之对应,即a=b1b2…b8,其中bi为相应摆法中第i行皇后所处的列数。已经知道8皇后问题一共有92组解(即92个不同的皇后串)。给出一个数b,要求输出第b个串。串的比...

2020-02-13 10:53:45 195

原创 百练#1183反正切函数的应用

描述反正切函数可展开成无穷级数,有如下公式(其中0 <= x <= 1) 公式(1)使用反正切函数计算PI是一种常用的方法。例如,最简单的计算PI的方法:PI=4arctan(1)=4(1-1/3+1/5-1/7+1/9-1/11+…) 公式(2)然而,这种方法的效率很低,但我们可以根据角度和的正切函数公式:tan(a+b)=[tan(a)+tan(b)]/[1-tan(a...

2020-02-12 14:04:49 364

原创 百练#2814拨钟问题

描述有9个时钟,排成一个3*3的矩阵。现在需要用最少的移动,将9个时钟的指针都拨到12点的位置。共允许有9种不同的移动。如下表所示,每个移动会将若干个时钟的指针沿顺时针方向拨动90度。移动 影响的时钟1 ABDE2 ABC3 BCEF4 ADG5 BDEFH6 CFI7 ...

2020-02-12 11:20:30 459 2

原创 百练#2812讨厌的青蛙

描述在韩国,有一种小的青蛙。每到晚上,这种青蛙会跳越稻田,从而踩踏稻子。农民在早上看到被踩踏的稻子,希望找到造成最大损害的那只青蛙经过的路径。每只青蛙总是沿着一条直线跳越稻田,而且每次跳跃的距离都相同。如下图所示,稻田里的稻子组成一个栅格,每棵稻子位于一个格点上。而青蛙总是从稻田的一侧跳进稻田,然后沿着某条直线穿越稻田,从另一侧跳出去如下图所示,可能会有多只青蛙从稻田穿越。青蛙的每一跳都恰...

2020-02-11 14:48:45 257

原创 百练#2706麦森数

描述加粗样式形如2p-1的素数称为麦森数,这时P一定也是个素数。但反过来不一定,即如果P是个素数。2p-1不一定也是素数。到1998年底,人们已找到了37个麦森数。最大的一个是P=3021377,它有909526位。麦森数有许多重要应用,它与完全数密切相关。任务:从文件中输入P (1000<P<3100000) ,计算2p-1的位数和最后500位数字(用十进制高精度数表示)输入...

2020-02-09 10:30:19 144

原创 百练#2952循环数

描述若一个n位的数字串满足下述条件,则称其是循环数(cyclic):将这个数字串视为整数(可能带有前导0),并用任意一个 1 到 n 之间(包含1和n)的整数去乘它时, 会得到一个将原数字串首尾相接后,再在某处断开而得到的新数字串所对应的整数。例如,数字 142857 是循环数,因为:142857 *1 = 142857142857 *2 = 285714142857 *3 = 42857...

2020-02-06 10:48:43 268

原创 百练#1835宇航员

描述问题描述:  宇航员在太空中迷失了方向,在他的起始位置现在建立一个虚拟xyz坐标系,称为绝对坐标系,宇航员正面的方向为x轴正方向,头顶方向为z轴正方向,则宇航员的初始状态如下图所示:现对六个方向分别标号,x,y,z正方向分别为0,1,2,负方向分别为3,4,5;称它们为绝对方向。宇航员在宇宙中只沿着与绝对坐标系xyz轴平行的方向行走,但是他不知道自己当前绝对坐标和自己面向的绝对方向。...

2020-02-05 11:32:11 76

原创 百练#1833排列

描述题目描述:大家知道,给出正整数n,则1到n这n个数可以构成n!种排列,把这些排列按照从小到大的顺序(字典顺序)列出,如n=3时,列出1 2 3,1 3 2,2 1 3,2 3 1,3 1 2,3 2 1六个排列。任务描述:给出某个排列,求出这个排列的下k个排列,如果遇到最后一个排列,则下1排列为第1个排列,即排列1 2 3…n。比如:n = 3,k=2 给出排列2 3 1,则它的下1...

2020-02-05 10:27:23 192

空空如也

空空如也

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

TA关注的人

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