自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 ERROR: Could not find a version that satisfies the requirement

ERROR: Could not find a version that satisfies the requirement

2022-08-22 16:42:25 855 1

原创 1030 Travel Plan (30分)(一个字短!)

1030 Travel Plan (30分)分析采用迪杰斯特拉算法,选取最短路径的同时记录前驱节点,若到同一点的最短路径不止一条,取花费最少的一条代码#include<iostream>#include<algorithm>#include<queue>#include<vector>using namespace std;int n, m, s, d, a, b, l, co, distTo[510], pre[510], marked[5

2020-06-05 17:02:40 171

原创 1029 Median (25分)(一个字短!)

1029 Median (25分)分析为了节省时间,先将第一个数组全部输入,而第二个数组一边输入一边找中位数,cnt记录在中位数之前一共有多少个数字,cnt_i用于计数在中位数之前,有多少个数字是属于第一个数组的,cnt_j用于计数在中位数之前有多少个数字是属于第二个数组的,当cnt_i+cnt_j=cnt时,表明中位数已经找到。当cnt_i为n或者cnt_j为m,则表示第一个数组或者第二个数组中的元素全部位于中位数之前。当cnt_i+cnt_j=cnt时,若cnt_i为n,则中位数为b,若cnt_

2020-06-05 13:47:00 184

原创 1028 List Sorting (25分)(一个字短!)

1028 List Sorting (25分)分析注意比较函数和结构体应尽量有助于缩短排序时间代码#include<iostream>#include<vector>#include<string>#include<string.h>#include<algorithm>using namespace std;int n, a;struct node { int id, score; string name; node(

2020-06-05 12:36:34 117

原创 1027 Colors in Mars (20分)(氵)

1027 Colors in Mars (20分)代码#include<iostream>using namespace std;int main() { int a; char v[13] = { '0','1','2','3','4','5','6','7','8','9','A','B','C' }; printf("#"); for (int i = 0; i < 3; ++i) { scanf("%d", &a); printf("%c%c", v

2020-06-05 10:37:46 139

原创 1025 PAT Ranking (25分)(水题)

1025 PAT Ranking (25分)分析先按组排序,后所有记录排序即可代码#include<iostream>#include<vector>#include<algorithm>#include<string>#include<string.h>using namespace std;struct node { string id; int score, group_id, l_rank, g_rank; nod

2020-06-05 10:26:47 165

原创 1022 Digital Library (30分)(一个字短!)

1022 Digital Library (30分)分析在输入时,将id插入到对应的特征下即可注意输出id时要按照%07d的格式输出代码#include<iostream>#include<map>#include<set>#include<string>using namespace std;map<string, set<int> > rcd[6];//1:title,2:author,3:keywords,4:

2020-06-04 13:39:18 237

原创 1021 Deepest Root (25分)(一个字短!)

1021 Deepest Root (25分)分析在深度优先遍历的同时,计算连通分量的个数,以及最大深度的节点,加入set中。第二次选第一次遍历得到的节点中的其中一个,开始深度优先遍历,得到的深度最深的节点也加入set中,从而得到所有的可以作为高度最大的树的根节点的节点。提供一个测试用例51 22 32 44 5代码#include<iostream>#include<vector>#include<set>using namespace st

2020-06-04 12:36:06 193

原创 1023 Have Fun with Numbers (20分)(一个字水)

1023 Have Fun with Numbers (20分)分析考察大整数的处理方法,对字符串进行乘二操作,并设置进位标记tag代码#include<iostream>#include<string>using namespace std;int cnt[10];string s;int main() { cin >> s; bool tag = false; for (int i = s.size() - 1; i >= 0; --i)

2020-06-04 11:46:24 190

原创 1024 Palindromic Number (25分)(一个字短!)

1024 Palindromic Number (25分)分析大整数加法,需要处理字符串相加,设置一个tag来标记进位代码#include<iostream>#include<string>#include<string.h>#include<algorithm>using namespace std;string getsum(string x, string y) { bool tag = false; for (int i = x.

2020-06-04 11:36:50 159

原创 1020 Tree Traversals (25分)(一个字短!)

1020 Tree Traversals (25分)分析给出二叉树的后序遍历序列和中序遍历序列,可唯一确定二叉树,从而可输出层序遍历序列代码#include<iostream>#include<queue>using namespace std;int n, post_odr[33], in_odr[33], level_odr[33], cnt = 0;typedef pair<pair<int, int>, pair<int, int&gt

2020-06-04 11:07:49 153

原创 1010 Radix (25分)(一个字短!)

1010 Radix (25分)分析二分法搜索目标进制,不失一般性,假设tag=1,初始的左边界设为b各位中最小数字加一,右边界设为a代码#include<iostream>#include<string>using namespace std;long long int getnum(string s, int d) { long long int a = 0, z = 1; for (int i = s.size() - 1; i >= 0; --i, z

2020-06-03 16:50:55 122

原创 1018 Public Bike Management (30分)(不长,不水)

1018 Public Bike Management (30分)分析求最短路的同时,要求带出的车子最少,再要求带回的车子最少迪杰斯特拉算法是贪心算法的一种,迪杰斯特拉算法能得出最优解,要求问题满足最优子结构条件。若携带车辆数目与带回车辆数目这两个尺度加到其中的话,满足最优子结构条件,即不能保证当前步骤选择的节点满足路径最短、带出车子最少、带回车子最少的条件时,之后的步骤也满足全局最优的条件反例如下:10 4 4 56 7 5 00 1 10 2 11 3 12 3 13 4 1因此

2020-06-03 16:36:08 225

原创 1019 General Palindromic Number (20分)(一个字水)

1019 General Palindromic Number (20分)代码#include<iostream>#include<vector>using namespace std;int main() { int a, b; vector<int>v; scanf("%d %d", &a, &b); while (a != 0) { v.push_back(a % b); a /= b; } bool tag = tru

2020-06-03 16:24:13 130

原创 1017 Queueing at Bank (25分)(一个字短!)

1017 Queueing at Bank (25分)分析在输入记录时,将五点之后到达的筛除利用priority_queue的特性,每次挑选出结束时间最早的窗口,记录等待时间,出队,并添加新的结束时间代码#include<iostream>#include<queue>#include<vector>using namespace std;int n, m, hh, mm, ss, serving_time, cnt = 0, wait_time = 0

2020-06-03 16:22:06 204

原创 1016 Phone Bills (25分)(一个字短!)

1016 Phone Bills (25分)分析将所有记录按照名字以及记录时间排序,将两条相邻的前后同名且前为on后为off的记录提取为一对用于计算通话时长的有效记录,并保存在map中对应的用户的记录中,最后遍历map计算每一对记录的时长、费用,以及总费用即可注意时长以及费用的计算可以从00:00:00开始计算然后相减代码#include<iostream>#include<vector>#include<algorithm>#include<str

2020-06-03 15:38:21 150

原创 1015 Reversible Primes (20分)(一个字水)

1015 Reversible Primes (20分)分析打印素数表,判断给定的数以及其在给定进制下的转置数是否为素数代码#include<iostream>using namespace std;int n, d, nonprime[100010];int getreverse(int n,int d) { int s = 0; while (n != 0) { s = s * d + n % d; n /= d; } return s;}int main(

2020-06-03 15:26:30 245

原创 1014 Waiting in Line (30分)(一个字短!)

1014 Waiting in Line (30分)分析按照时间遍历,记录每位顾客的结束时间即可代码#include<iostream>#include<vector>#include<queue>using namespace std;int n, m, k, q, a;vector<int> f, service_time;vector<vector<pair<int,int> > >w;//窗口,记

2020-06-03 15:11:12 121

原创 1013 Battle Over Cities (25分)(一个字短!)

1013 Battle Over Cities (25分)分析依次将每个点标为已访问状态,计算连通分量个数代码#include<iostream>#include<vector>using namespace std;vector<vector<int> >g;int n, m, k, a, b, marked[1010];int main() { scanf("%d %d %d", &n, &m, &k); g.

2020-06-03 14:56:36 103

原创 1012 The Best Rank (25分)(一个字短!)

1012 The Best Rank (25分)分析依次对各个成绩排序,并按照优先级选取最高排名代码#include<iostream>#include<vector>#include<algorithm>#include<map>using namespace std;vector<pair<int, vector<int> > >rcd;map<int, vector<int> &g

2020-06-03 14:53:38 113

原创 1011 World Cup Betting (20分)(一个字水)

1011 World Cup Betting (20分)水题#include<iostream>using namespace std;int main() { char d[3] = { 'W','T','L' }; int i = 3, x; double s = 1, y; while (--i >= 0) { double m = -1; for (int j = 0; j < 3; ++j) { scanf("%lf", &y);

2020-06-03 14:37:10 128

原创 1009 Product of Polynomials (25分)(一个字短!)

1009 Product of Polynomials (25分)题目This time, you are supposed to find A×BA\times BA×B where AAA and BBB are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the information

2020-05-29 21:17:51 275

原创 1008 Elevator (20分)(一个字短!)

1008 Elevator (20分)题目The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one

2020-05-29 21:06:54 132

原创 1007 Maximum Subsequence Sum (25分)(一个字短!)

1007 Maximum Subsequence Sum (25分)题目Given a sequence of K integers { N​1​​, N2​​, …, N​k }. A continuous subsequence is defined to be { Ni, N​i+1​​, …, N​j } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum o

2020-05-29 21:00:47 159

原创 1006 Sign In and Sign Out (25分)(一个字短!)

1006 Sign In and Sign Out (25分)题目At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in’s and out’s, you are supposed to fin

2020-05-29 20:51:22 150

原创 1005 Spell It Right (20分)(一个字短!)

1005 Spell It Right (20分)题目Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Each case occupies one line whic

2020-05-29 20:46:32 234

原创 1004 Counting Leaves (30分)(一个字短!)

1004 Counting Leaves (30分)题目A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one test case. Each case starts with a line containing 0&

2020-05-29 20:41:32 190

原创 1003 Emergency (25分)(一个字短!)

1003 Emergency (25分)题目As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any p

2020-05-29 20:20:38 171

原创 1002 A+B for Polynomials (25分)(一个字短!)

1002 A+B for Polynomials (25分)题目This time, you are supposed to find A+BA+BA+B where AAA and BBB are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polyno

2020-05-29 20:08:57 540

原创 1001 A+B Format (20分)(一个字短!)

1001 A+B Format (20分)题目Calculate a+b and output the sum in standard format – that is, the digits must be separated into groups of three by commas (unless there are less than four digits).Input Specification:Each input file contains one test case. Each

2020-05-29 19:58:51 366

空空如也

空空如也

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

TA关注的人

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