PAT 1021-1030 题解】的更多相关文章

dfs求最大层数并查集求连通个数 #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <string> #include <vector> using namespace std; /* dfs求最大层数 并查集求连通个数 */ +; int n; ; //最大层数 vector<int>deepro…
模板题最短路+输出路径如果最短路不唯一,输出cost最小的 #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <cmath> #include <queue> #define INF 0x3f3f3f3f using namespace std; ; int n,m,s,t; struct Edge{ int…
1021 Deepest Root (25)(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 is called the deepest…
1030 完美数列 给定一个正整数数列,和正整数p,设这个数列中的最大值是M,最小值是m,如果M <= m * p,则称这个数列是完美数列. 现在给定参数p和一些正整数,请你从中选择尽可能多的数构成一个完美数列. 输入格式: 输入第一行给出两个正整数N和p,其中N(<= 10^5^)是输入的正整数的个数,p(<= 10^9^)是给定的参数.第二行给出N个正整数,每个数不超过10^9^. 输出格式: 在一行中输出最多可以选择多少个数可以用它们组成一个完美数列. 输入样例: 10 8 2 3…
题目链接:1030 完美数列 (25 point(s)) 给定一个正整数数列,和正整数 \(p\),设这个数列中的最大值是 \(M\),最小值是 \(m\),如果 \(M≤mp\),则称这个数列是完美数列. 现在给定参数 \(p\) 和一些正整数,请你从中选择尽可能多的数构成一个完美数列. 输入格式: 输入第一行给出两个正整数 \(N\) 和 \(p\),其中 \(N\)(\(≤10^5\))是输入的正整数的个数,\(p\)(\(≤10^9\))是给定的参数.第二行给出 \(N\) 个正整数,每…
2019 秋季 PAT (Advanced Level) C++题解 考试拿到了满分但受考场状态和知识水平所限可能方法不够简洁,此处保留记录,仍需多加学习.备考总结(笔记目录)在这里 7-1 Forever (20 分) "Forever number" is a positive integer A with K digits, satisfying the following constrains: the sum of all the digits of A is m; the…
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 between his/her starting…
https://www.patest.cn/contests/pat-a-practise/1030 找最短路,如果有多条找最小消耗的,相当于找两次最短路,可以直接dfs,数据小不会超时. #include<cstdio> #include<string> #include<cstring> #include<vector> #include<iostream> #include<queue> #include<bitset&g…
1030. 完美数列(25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CAO, Peng 给定一个正整数数列,和正整数p,设这个数列中的最大值是M,最小值是m,如果M <= m * p,则称这个数列是完美数列. 现在给定参数p和一些正整数,请你从中选择尽可能多的数构成一个完美数列. 输入格式: 输入第一行给出两个正整数N和p,其中N(<= 105)是输入的正整数的个数,p(<= 109)是给定的参数.第二行给出N个…
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 is called the deepest root…