
dfs
文章平均质量分 67
小雪乃
这个作者很懒,什么都没留下…
展开
-
PAT 甲级 1021. Deepest Root (25)
A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root ...原创 2017-09-22 17:43:12 · 191 阅读 · 0 评论 -
蓝桥杯 算法训练 数字三角形
问题描述 (图3.1-1)示出了一个数字三角形。 请编一个程序计算从顶至底的某处的一条路 径,使该路径所经过的数字的总和最大。 ●每一步可沿左斜线向下或右斜线向下走; ●1<三角形行数≤100; ●三角形中的数字为整数0,1,…99; . (图3.1-1) 输入格式 文件中首先读到的是三角形的行数。 接下来描述整个三角形 输出格式 最大总和(整原创 2017-12-24 11:37:08 · 373 阅读 · 0 评论 -
蓝桥杯 算法训练 未名湖边的烦恼
问题描述 每年冬天,北大未名湖上都是滑冰的好地方。北大体育组准备了许多冰鞋,可是人太多了,每天下午收工后,常常一双冰鞋都不剩。 每天早上,租鞋窗口都会排起长龙,假设有还鞋的m个,有需要租鞋的n个。现在的问题是,这些人有多少种排法,可以避免出现体育组没有冰鞋可租的尴尬场面。(两个同样需求的人(比如都是租鞋或都是还鞋)交换位置是同一种排法) 输入格式 两个整数,表示m和n 输出格式原创 2017-12-10 19:52:52 · 153 阅读 · 0 评论 -
蓝桥杯 算法训练 6-1 递归求二项式系数值
问题描述样例输入 一个满足题目要求的输入范例。 3 10 样例输出 与上面的样例输入对应的输出。数据规模和约定 输入数据中每一个数的范围。 例:结果在int表示时不会溢出。#include <iostream>#include <vector>#include <string>#include <cctype>using namespace std;int dfs(int原创 2017-12-10 19:36:58 · 166 阅读 · 0 评论 -
PAT 甲级 1131. Subway Map (30)
In the big cities, the subway systems always look so complex to the visitors. To give you some sense, the following figure shows the map of Beijing subway. Now you are supposed to help people with you原创 2017-10-26 04:36:10 · 231 阅读 · 0 评论 -
PAT 甲级 1130. Infix Expression (25)
Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Each input file contains on原创 2017-10-26 02:50:25 · 190 阅读 · 0 评论 -
PAT 甲级 1126. Eulerian Path (25)
In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the same vertex. They were first原创 2017-10-23 05:24:27 · 256 阅读 · 0 评论 -
PAT 甲级 1094. The Largest Generation (25)
A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Inpu原创 2017-10-06 16:55:31 · 196 阅读 · 0 评论 -
PAT 甲级 1090. Highest Price in Supply Chain (25)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on原创 2017-10-06 15:19:51 · 219 阅读 · 0 评论 -
PAT 甲级 1087. All Roads Lead to Rome (30)
Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:E原创 2017-10-05 20:14:08 · 375 阅读 · 0 评论 -
PAT 甲级 1115. Counting Nodes in a BST (30)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than or equal to the node’s key. The原创 2017-10-18 08:02:16 · 254 阅读 · 0 评论 -
PAT 甲级 1079. Total Sales of Supply Chain (25)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on原创 2017-10-04 20:23:31 · 217 阅读 · 0 评论 -
PAT 甲级 1106. Lowest Price in Supply Chain (25)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on原创 2017-10-09 20:35:14 · 191 阅读 · 0 评论 -
PAT 甲级 1053. Path of Equal Weight (30)
Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weight of a path from R to L is defined to be the sum of the weights of all the nodes along the path from R原创 2017-09-30 21:51:50 · 193 阅读 · 0 评论 -
PAT 甲级 1103. Integer Factorization (30)
The K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K-P factorization of N for any positive原创 2017-10-09 15:16:21 · 192 阅读 · 0 评论 -
PAT甲级 1111. Online Map (30)
Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other is the fastest. It is gu原创 2017-10-18 02:55:00 · 211 阅读 · 0 评论 -
PAT 甲级 1034. Head of a Gang (30)
One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be t原创 2017-09-24 18:21:13 · 195 阅读 · 0 评论 -
PAT 甲级 1030. Travel Plan (30)
A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path b原创 2017-09-24 14:50:23 · 153 阅读 · 0 评论 -
蓝桥杯 算法提高 金陵十三钗
金陵十三钗 本题难度:难 本题占分比例:5% 问题描述 在电影《金陵十三钗》中有十二个秦淮河的女人要自我牺牲代替十二个女学生去赴日本人的死亡宴会。为了不让日本人发现,自然需要一番乔装打扮。但由于天生材质的原因,每个人和每个人之间的相似度是不同的。由于我们这是编程题,因此情况就变成了金陵n钗。给出n个女人和n个学生的相似度矩阵,求她们之间的匹配所能获得的最大相似度。 所谓相似原创 2017-12-18 21:42:21 · 503 阅读 · 0 评论