自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 1147 Heaps (30分)

1147 Heaps (30分) AC代码 #include <iostream> #include <cstdio> #include <cstring> using namespace std; int m,n; bool isHeap(int u,int nums[],int len,int index){ if(u>=len) return...

2020-03-17 11:34:59 141

原创 1045 Favorite Color Stripe (30分)

1045 Favorite Color Stripe (30分) Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted piec...

2020-03-11 09:59:10 153

原创 1007 Maximum Subsequence Sum (25分)

1007 Maximum Subsequence Sum (25分) 题目要求求出最大连续子数组的和,动态规划中有这种常规题型,我这里使用求最大回文串的动规来求解这道题。 确定状态 题目要求输出所求和的同时,还要输出所求序列的第一个数和最后一个数。因此我选着用开一个二维数组//dp[maxn][maxn], dp[i][j]表示数组从i下标到j下标的和。 转移方程 dp[i][j]=d[i][j-...

2020-03-09 09:26:29 172

原创 1087 All Roads Lead to Rome (30分)

1087 All Roads Lead to Rome (30分) we are supposed to find the route with the least cost. If such a route is not unique, the one with the maximum happiness will be recommanded. If such a route is still...

2020-03-07 18:23:54 133

原创 1079 Total Sales of Supply Chain (25分)

1079 Total Sales of Supply Chain (25分) 题目大意: 树形结构,根结点是供应商提供产品单位价格 为P,经过一层经销商或者零售商,单位价格增加R%。终端结点给出产品数量,要求给出所有终端结点产品的总价格。 每层都增加R%,很明显应该用树的层次遍历,算出每层的单位价格,遍历到终端节点时,将总价格算出。 AC代码: #include <iostream> ...

2020-03-07 11:04:14 164

原创 1063 Set Similarity (25分)

1063 Set Similarity (25分) Given two sets of integers, the similarity of the sets is defined to be Nc​ /Nt​​ ×100%, where N​c​​ is the number of distinct common numbers shared by the two sets, and Nt ...

2020-03-05 09:08:38 146

原创 1024 Palindromic Number (25分)

1024 Palindromic Number (25分) A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit n...

2020-03-02 15:50:00 114

原创 1022 Digital Library (30分)

1022 Digital Library (30分) A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned...

2020-03-02 15:09:54 111

原创 1017 Queueing at Bank (25分)(优先级队列)

1017 Queueing at Bank (25分) Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait ...

2020-03-01 20:06:53 240

原创 1016 Phone Bills (25分)

1016 Phone Bills (25分) A long-distance telephone company charges its customers by the following rules: Making a long-distance call costs a certain amount per minute, depending on the time of day when ...

2020-03-01 15:19:14 192

原创 1013 Battle Over Cities (25分)

1013 Battle Over Cities (25分) It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We m...

2020-03-01 10:12:49 179

原创 1012 The Best Rank (25 分)

1012 The Best Rank (25分) To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Lin...

2020-03-01 08:31:45 221

原创 1030 完美数列 (25分)

1030 完美数列 (25分) 给定一个正整数数列,和正整数 p,设这个数列中的最大值是 M,最小值是 m,如果 M≤mp,则称这个数列是完美数列。现在给定参数 p 和一些正整数,请你从中选择尽可能多的数构成一个完美数列。 输入格式: 输入第一行给出两个正整数 N 和 p,其中 N(≤10^​5​​ )是输入的正整数的个数,p(≤10^​9​​ )是给定的参数。第二行给出 N 个正整数,每个数不超...

2020-02-25 10:49:15 128

原创 1025 反转链表 (25分)

1025 反转链表 (25分) 给定一个常数 K 以及一个单链表 L,请编写程序将 L 中每 K 个结点反转。例如:给定 L 为 1→2→3→4→5→6,K 为 3,则输出应该为 3→2→1→6→5→4;如果 K 为 4,则输出应该为 4→3→2→1→5→6,即最后不到 K 个元素不反转。 输入格式: 每个输入包含 1 个测试用例。每个测试用例第 1 行给出第 1 个结点的地址、结点总个数正整数 ...

2020-02-25 09:59:25 93

原创 1090 危险品装箱 (25分)

1090 危险品装箱 (25分) 集装箱运输货物时,我们必须特别小心,不能把不相容的货物装在一只箱子里。比如氧化剂绝对不能跟易燃液体同箱,否则很容易造成爆炸。 本题给定一张不相容物品的清单,需要你检查每一张集装箱货品清单,判断它们是否能装在同一只箱子里。 输入格式: 输入第一行给出两个正整数:N (≤10^​4​​ ) 是成对的不相容物品的对数;M (≤100) 是集装箱货品清单的单数。随后数据分...

2020-02-23 20:32:57 334 2

原创 PAT 1070结绳

1070 结绳 (25分) 给定一段一段的绳子,你需要把它们串成一条绳。每次串连的时候,是把两段绳子对折,再如下图所示套接在一起。这样得到的绳子又被当成是另一段绳子,可以再次对折去跟另一段绳子串连。每次串连后,原来两段绳子的长度就会减半。给定 N 段绳子的长度,你需要找出它们能串成的绳子的最大长度。 输入格式: 每个输入包含 1 个测试用例。每个测试用例第 1 行给出正整数 N (2≤N≤10​^...

2020-02-22 09:16:24 112

原创 PAT 1050 螺旋矩阵

1050 螺旋矩阵 (25分) 本题要求将给定的 N 个正整数按非递增的顺序,填入“螺旋矩阵”。所谓“螺旋矩阵”,是指从左上角第 1 个格子开始,按顺时针螺旋方向填充。要求矩阵的规模为 m 行 n 列,满足条件:m×n 等于 N;m≥n;且 m−n 取所有可能值中的最小值。 输入格式: 输入在第 1 行中给出一个正整数 N,第 2 行给出 N 个待填充的正整数。所有数字不超过 10​4,相邻数字以...

2020-02-15 15:00:19 127

原创 PAT 1049 数列的片段和

数列的片段和 (20分) 给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段。例如,给定数列 { 0.1, 0.2, 0.3, 0.4 },我们有 (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0.4) (0.3) (0.3, 0.4) (0.4) 这 10 个片段。 ...

2020-02-15 12:57:08 79

空空如也

空空如也

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

TA关注的人

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