- 博客(42)
- 资源 (2)
- 问答 (1)
- 收藏
- 关注
原创 例题6-21 系统依赖(System Dependencies, ACM/ICPC World Finals 1997, UVa506)
原题链接:https://vjudge.net/problem/UVA-506分类:杂题备注:中级模拟注意:在安装和删除的时候,依赖的依赖也要考虑进来。LIST的输出顺序是安装顺序。如果依赖由隐式(间接)安装变成了显式(直接)安装,即对该依赖出现了INSTALL语句,则REMOVE语句未对其直接作用时,不可删除该依赖。代码如下:#include<iostream>#include<string>#include<sstream>#include<ve
2020-05-31 11:13:53 292
原创 习题11-1 网页跳跃(Page Hopping, ACM/ICPC World Finals 2000, UVa821)
原题链接:https://vjudge.net/problem/UVA-821分类:图论备注:Floyd算法代码如下:#include<cstdio>#include<cstring>#include<vector>#include<map>using namespace std;const int inf = 0x3f3f3f3f;const int maxn = 100 + 5;int g[maxn][maxn];int main(
2020-05-30 22:59:13 236
原创 习题7-1 消防车(Firetruck,ACM/ICPC World Finals 1991, UVa208)
原题链接:https://vjudge.net/problem/UVA-208备注:搜索分类:DFS代码如下:#include<cstdio>#include<cstring>#include<queue>#include<vector>#include<algorithm>using namespace std;int kase, k, vis[25], pre[25], num;vector<int>e[25]
2020-05-30 22:37:54 770
原创 例题6-20 理想路径(Ideal Path, NEERC 2010, UVa1599)
原题链接:https://vjudge.net/problem/UVA-1599分类:图备注:BFS,逆搜索思路按照紫书上的,先在终点开始BFS求出每个点到终点的距离,再从起点开始搜索,每次找邻接结点中能更进一步的点,要比较颜色的字典序来筛选,把最小的都留下。重复此步骤,每次输出最小颜色值即可。数据挺大的,花了好久时间,终于不是TLE了,不得不说map是真的慢,在速度方面似乎越原始的东西越好,所以直接用结构体来存边的权值。注意不仅仅是在逆向BFS更新距离时要注意用vis[]数组防止点重复入队,在从
2020-05-30 14:53:58 355
原创 习题 6-14 检查员的难题(Inspector’s Dilemma, ACM/ICPC Dhaka 2007, UVa12118)
原题链接:https://vjudge.net/problem/UVA-12118分类:图备注:欧拉路分析:要求每条指定边都过一次,显示与欧拉路类似先得出各个点集(连通图的数目),然后检查每个点集是否为欧拉路欧拉路的条件为度数为奇数的点的数目为0或者2,连通图中度数为奇数的点个数必定为偶数个,若大于2,则需要把多余的点连起来,即加上(x-2)/2条边最后把各个点集相连,即加上 点集数目-1 条边注意给定边的数目为0时,直接输出0代码如下:#include<cstdio>
2020-05-30 10:55:20 233
原创 例题6-16 单词(Play On Words, UVa 10129)
原题链接:https://vjudge.net/problem/UVA-10129分类:图备注:欧拉路有向欧拉道路的条件:1,底图(忽略边方向之后得到的无向图)连通;2.度要满足欧拉路的条件。代码如下:#include<iostream>#include<cstring>#include<string>#include<map>using namespace std;const int maxn = 100000 + 5;int T, N
2020-05-30 09:23:56 293
原创 例题11-4 电话圈(Calling Circles, ACM/ICPC World Finals 1996, UVa247)
原题链接:https://vjudge.net/problem/UVA-247分类:图论备注:Floyd传递闭包注意:逗号后面有空格,否则显示WA代码如下:#include<iostream>#include<map>#include<vector>#include<cstring>using namespace std;const int maxn = 30;string name[maxn];int n, m, fa[maxn],
2020-05-29 16:26:57 182
原创 例题11-2 苗条的生成树(Slim Span, ACM/ICPC Japan 2007, UVa1395)
原题链接:https://vjudge.net/problem/UVA-1395分类:图论备注:kruskal算法,暴力代码如下:#include<cstdio>#include<algorithm>using namespace std;const int inf = 10000 + 5;const int maxn = 100 + 5;const int maxm = 5000 + 5;int u[maxm], v[maxm], w[maxm], r[maxm
2020-05-29 15:55:44 281
原创 HDU - 1102 Constructing Roads(kruskal算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1102Problem DescriptionThere are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected,
2020-05-27 23:09:45 112
原创 HDU - 2433 Travel(BFS+思维)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2433Problem DescriptionOne day, Tom traveled to a country named BGM. BGM is a small country, but there are N (N <= 100) towns in it. Each town products one kind of food, the food will be transported to al
2020-05-27 18:00:13 143
原创 HDU - 2680 Choose the best route(Bellman-Ford)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2680Problem DescriptionOne day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traf
2020-05-27 16:18:11 88
原创 HDU - 1596 find the safest road(Floyd算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1596Problem DescriptionXX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每一条路有一个安全系数s,s是在 0 和 1 间的实数(包括0,1),一条从u 到 v 的通道P 的安全度为Safe§ = s(e1)*s(e2)…*s(ek) e1,e2,ek是P 上的边 ,现在8600 想出去旅游,面对这这么多的路,他想找一条最安全的路。但是8600 的数学不
2020-05-27 14:47:27 114
原创 HDU - 1874 畅通工程续(最短路初级)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1874Problem Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。每组数据第一行包含两个正整数N和M(0<N
2020-05-27 14:34:35 401
原创 HDU - 4283 You Are the One(区间DP)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4283Problem Description The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the show itself. The show is hold in the Small hall, so
2020-05-27 06:54:18 100
转载 证明两数乘积等于其最小公倍数和最大公因数乘积(转载)
原文链接:https://blog.csdn.net/qq_40930559/article/details/96147354设gcd(a,b)=c,lcm(a,b)=d,即ab的最大公因数为c,最小公倍数为d,则一定有a=k1c , b=k2c (1) a=d/t1 b=d/t2 (2),其中k1,k2必然互质(反证法:假设k1,k2不互质,则必定有一个大于1的最大公因数,设其为x,则有a=k1/x * xc, b=k2/x * xc,此时k1/x和k2/x已经互质,但是明显a
2020-05-26 20:16:59 1051
原创 程序设计与算法(三)期末考试(2020春季)
001:编程填空:二进制输出输入第一行是整数n(n<15),表示有n个正整数要处理第二行是n个正整数输出对每个给出的正整数,输出其二进制表示。不足31位则用0补齐到31位样例输入31 2 3样例输出000000000000000000000000000000100000000000000000000000000000100000000000000000000000000000011#include <iostream>#include <string&
2020-05-25 21:51:02 1267
原创 HDU - 1233 还是畅通工程(最优生成树入门)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1233Problem Description某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( < 100 );随后的N(N-1)/2行对应
2020-05-25 08:14:20 220
原创 HDU - 2544 最短路(经典题:一题多解)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544代码如下:#include<cstdio>#include<algorithm>using namespace std;const int inf = 0x3f3f3f3f;const int maxn = 100 + 5;int g[maxn][maxn],...
2020-05-23 10:34:26 382
原创 HDU - 4911 Inversion(归并排序)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4911Problem Descriptionbobo has a sequence a1,a2,…,an. He is allowed to swap two adjacent numbers for no more than k times.Find the minimum number of inversions after his swaps.Note: The number of inversio
2020-05-18 15:06:11 111
原创 POJ - 2388 Who’s in the Middle(快速排序)
题目链接:https://vjudge.net/problem/POJ-2388FJ is surveying his herd to find the most average cow. He wants to know how much milk this ‘median’ cow gives: half of the cows give as much or more than the median; half give as much or less.Given an odd number of
2020-05-15 23:48:07 132
原创 HDU - 1425 sort(堆排序)
题目链接:http://acm.hdu.edu.cn/userstatus.php?user=55190123Problem Description给你n个整数,请按从大到小的顺序输出其中前m大的数。Input每组测试数据有两行,第一行有两个数n,m(0<n,m<1000000),第二行包含n个各不相同,且都处于区间[-500000,500000]的整数。Output对每组测试数据按从大到小的顺序输出前m大的数。Sample Input5 33 -35 92 213 -644
2020-05-14 07:51:31 125
原创 51Nod - 1021 石子归并(区间DP)
题目链接:https://vjudge.net/problem/51Nod-1021N堆石子摆成一条线。现要将石子有次序地合并成一堆。规定每次只能选相邻的2堆石子合并成新的一堆,并将新的一堆石子数记为该次合并的代价。计算将N堆石子合并成一堆的最小代价。例如: 1 2 3 4,有不少合并方法1 2 3 4 => 3 3 4(3) => 6 4(9) => 10(19)1 2 3 4 => 1 5 4(5) => 1 9(14) => 10(24)1 2 3 4 =
2020-05-13 21:32:06 130
原创 程序设计与算法(三)第09周测验(2020春季)
001:Set查看提交统计提问总时间限制: 5000ms 内存限制: 100000kB描述现有一整数集(允许有重复元素),初始为空。我们定义如下操作:add x 把x加入集合del x 把集合中所有与x相等的元素删除ask x 对集合中元素x的情况询问对每种操作,我们要求进行如下输出。add 输出操作后集合中x的个数del 输出操作前集合中x的个数ask 先输出0或1表示x是否曾被加入集合(0表示不曾加入),再输出当前集合中x的个数,中间用空格格开。输入第一行是一个整数n,表示命.
2020-05-13 15:20:44 689
原创 程序设计与算法(三)第05周测验(2020春季)
题目链接:http://cxsjsxmooc.openjudge.cn/2020t3spring5/001:全面的MyString输入无输出abcd-efgh-abcd-abcd-abcd-efgh-efgh-cabcd-ijAl-ijAl-mnopqrst-abcd-abcd-qrst-abcd- uvw xyzaboutbigmetakeabcdq...
2020-05-12 20:35:06 520
原创 程序设计与算法(三)第08周测验(2020春季)
001:goodcopy输入第一行是整数 t,表示数据组数每组数据:第一行是整数 n , n < 50第二行是 n 个整数第三行是 n 个字符串输出将输入的整数原序输出两次,用","分隔然后将输入的字符串原序输出两次,也用 ","分隔样例输入241 2 3 4Tom Jack Marry Peking10Ted样例输出1,2,3,4,1,2,3,4,Tom,Jack,Marry,Peking,Tom,Jack,Marry,Peking,0,0,Ted
2020-05-11 18:02:14 655
原创 程序设计与算法(三)第07周测验(2020春季)
001:简单的SumArray输入无输出TomJackMaryJohn10#include <iostream>#include <string>using namespace std;template <class T>T SumArray( // 在此处补充你的代码//—————————————————— T* s, T* e){ T sum = *s; for (s++; s != e; s++) sum += *s; re
2020-05-10 23:03:59 692
原创 HDU - 3791 二叉搜索树
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3791Problem Description判断两序列是否为同一二叉搜索树序列Input开始一个数n,(1<=n<=20) 表示有n个需要判断,n= 0 的时候输入结束。接下去一行是一个序列,序列长度小于10,包含(0~9)的数字,没有重复数字,根据这个序列可以构造出一颗二叉搜索树。接下去的n行有n个序列,每个序列格式跟第一个序列一样,请判断这两个序列是否能组成同一颗二叉搜索树。Outp
2020-05-09 08:03:20 124
原创 HDU - 3999 The order of a Tree (BST初识)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999Problem DescriptionAs we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely:insert a key k to a empty tree, then the tree become a tree withonly
2020-05-08 23:04:58 355
原创 POJ - 1163 The Triangle(记忆化搜索)
题目链接:https://vjudge.net/problem/POJ-1163 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5(Figure 1)Figure 1 shows a number triangle. Write a program that calculates the high...
2020-05-07 21:29:01 135
原创 程序设计与算法(三)第06周测验(2020春季)
001:看上去像多态输入无输出D::FunB::FunD::FunnBVal=2nBVal=24nDVal=8B::FunnBVal=12样例输入无样例输出D::FunB::FunD::FunnBVal=2nBVal=24nDVal=8B::FunnBVal=12代码如下:#include <iostream>using names...
2020-05-07 20:06:57 301
原创 程序设计与算法(三)第03周测验(2020春季)
题目链接:http://cxsjsxmooc.openjudge.cn/2020t3spring3/001:返回什么才好呢输入多组数据,每组一行,是整数 m 和 n输出先输出一行:123然后,对每组数据,输出两行,第一行是m,第二行是n样例输入2 34 5样例输出1232345代码如下:#include <iostream>using name...
2020-05-07 18:04:17 420
原创 HDU - 2050 折线分割平面
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2050Problem Description我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示。Input输入数据的第一行是一个整数C,表示测试实例的个数,然后是...
2020-05-07 07:58:41 163
原创 程序设计与算法(三)第02周测验(2020春季)
题目链接:001:编程填空:学生信息处理程序描述实现一个学生信息处理程序,计算一个学生的四年平均成绩。要求实现一个代表学生的类,并且类中所有成员变量都是【私有的】。补充下列程序中的 Student 类以实现上述功能。输入输入数据为一行,包括:姓名,年龄,学号,第一学年平均成绩,第二学年平均成绩,第三学年平均成绩,第四学年平均成绩。其中姓名为由字母和空格组成的字符串(输入保证姓名...
2020-05-06 17:10:58 1438
原创 HDU - 1846 Brave Game(巴什游戏)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1846Problem Description十年前读大学的时候,中国每年都要从国外引进一些电影大片,其中有一部电影就叫《勇敢者的游戏》(英文名称:Zathura),一直到现在,我依然对于电影中的部分电脑特技印象深刻。今天,大家选择上机考试,就是一种勇敢(brave)的选择;这个短学期,我们讲的是博...
2020-05-05 14:53:56 147
原创 程序设计与算法(三)第01周测验(2020春季)
题目链接:http://cxsjsxmooc.openjudge.cn/2020t3spring1/001:简单的swap输入无输出5,3样例输入无样例输出5,3代码如下:#include <iostream>using namespace std;class A{public: int x; int getX() { return x; }};...
2020-05-05 12:15:06 1216
原创 程序设计与算法(三)第04周测验(2020春季)
题目链接:http://cxsjsxmooc.openjudge.cn/2020t3spring4/001:MyString输入多组数据,每组一行,是两个不带空格的字符串输出对每组数据,先输出一行,打印输入中的第一个字符串三次然后再输出一行,打印输入中的第二个字符串三次样例输入abc def123 456样例输出abc,abc,abcdef,def,def123,123...
2020-05-05 12:01:11 604
原创 POJ - 2533 Longest Ordered Subsequence (LIS)
题目链接:https://vjudge.net/problem/POJ-2533A numeric sequence of ai is ordered if a1 < a2 < … < aN. Let the subsequence of the given numeric sequence ( a1, a2, …, aN) be any sequence ( ai1, ai2...
2020-05-05 07:55:18 131
原创 HDU - 1257 最少拦截系统(LIS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1257Problem Description某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截...
2020-05-04 23:54:46 132
原创 HDU - 1159 Common Subsequence (LCS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159Problem DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1...
2020-05-03 19:29:23 134
原创 HDU - 2069 Coin Change
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069Problem DescriptionSuppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for ...
2020-05-03 15:31:32 183
请问有什么数据库使用了多粒度封锁协议?
2022-01-07
TA创建的收藏夹 TA关注的收藏夹
TA关注的人