自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 PAT 甲级 1118(Birds in Forest)

PAT 甲级 1042题目要求翻译代码思路题目要求翻译一幅画里面的鸟为同一棵树上的,问有多少棵树和多少只鸟,以及对于两只鸟判断是否在同一个树上。代码#include<iostream>#include<vector>#include<cstring>#include<algorithm>#include<set>using namespace std;set<int> ids;int Rank[10010],p

2020-09-19 20:02:41 217 1

原创 PAT 甲级 1114(Family Property)

PAT 甲级 1042题目要求翻译代码思路题目要求翻译给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数、人均房产面积及房产套数。首先在第一行输出家庭个数(所有有亲属关系的人都属于同一个家庭)。随后按下列格式输出每个家庭的信息:家庭成员的最小编号 家庭人口数 人均房产套数 人均房产面积。其中人均值要求保留小数点后3位。家庭信息首先按人均面积降序输出,若有并列,则按成员编号的升序输出。代码#include<iostream>#include<algorithm&

2020-09-19 17:55:25 224 1

原创 PAT 甲级 1042(Be Unique)

PAT 甲级 1042题目要求翻译代码思路题目要求Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid “inside jobs” where employees collaborate with gamblers by performing inadequate sh

2020-09-17 19:25:29 231

原创 PAT 甲级 1041 (Be Unique)

PAT 甲级 1041题目要求翻译代码思路题目要求Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,10410^4104​​ ]. The first one who bets on a unique number wins

2020-09-17 18:38:57 132

原创 PAT 甲级 1040 (Longest Symmetric String)

PAT 甲级 1039题目要求翻译代码思路题目要求Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given Is PAT&TAP symmetric?, the longest symmetric sub-string is s PAT&TAP s, hence you must output 11.Input Specifi

2020-09-17 18:27:12 132

原创 PAT 甲级 1039 (Course List for Student )

PAT 甲级 1039题目要求翻译代码思路题目要求Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes for a query.Input Specificat

2020-09-17 15:03:50 95

原创 PAT 甲级 1038 (Recover the Smallest Number )

PAT 甲级 1037题目要求翻译代码思路题目要求Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229-87 or 0229-32-87-321-3214 wi

2020-09-17 15:01:20 144

原创 PAT 甲级 1037 (Magic Coupon )

PAT 甲级 1037题目要求翻译代码思路题目要求翻译给两个集合,分别从两个集合中取值相乘,找最大的和代码#include<iostream>#include<algorithm>using namespace std;int main(){ int n1,n2,i,j,sum=0; int a[100000],b[100000]; cin>>n1; for(i=0;i<n1;i++) cin>>a[i

2020-09-16 15:40:57 107

原创 PAT 甲级 1036 (Boys vs Girls)

PAT 甲级 1036题目要求翻译代码思路题目要求This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contains one test case. Each case contains a

2020-09-16 13:52:42 139

原创 PAT 甲级 1035 (Password)

PAT 甲级 1031题目要求翻译代码思路题目要求To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) fr

2020-09-16 11:52:38 139

原创 PAT 甲级 1032 (Sharing)

PAT 甲级 1032题目要求翻译代码思路题目要求翻译输出第一个共用的节点地址代码#include<iostream>using namespace std;struct NODE{ int next; char data; bool flag;};NODE node[100001];int main(){ int f1,f2,num; cin>>f1>>f2>>num; int ad,

2020-09-16 11:25:45 100

原创 PAT 甲级 1031 (Hello World for U)

PAT 甲级 1031题目要求翻译代码思路题目要求翻译将字符串打印成U型代码#include<iostream>#include<string.h>using namespace std;int main(){ char s[100]; scanf("%s",s); int len=strlen(s); int n1 = (len+2) / 3; int n2 = len +2 - 2*n1; int p=0,q=

2020-09-15 22:20:51 108

原创 PAT 甲级 1030 (Travel Plan)

PAT 甲级 1030题目要求翻译代码思路题目要求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 city

2020-09-15 19:23:24 165

原创 PAT 甲级 1029 (Median)

PAT 甲级 1029题目要求翻译代码思路题目要求Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 } is 15. The median of two sequen

2020-09-15 15:32:54 144

原创 PAT 甲级 1028 (List Sorting)

PAT 甲级 1028题目要求翻译代码思路题目要求Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first line contains two integers N (≤10510^5105) and C

2020-09-15 12:00:15 101

原创 PAT 甲级 1027 (Colors in Mars)

PAT 甲级 1027题目要求翻译代码思路题目要求People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 digits for Green, and the last 2

2020-09-15 11:09:50 91

原创 PAT 甲级 1025 (PAT Ranking)

PAT 甲级 1025题目要求翻译代码思路题目要求Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists will be merged immediately aft

2020-09-12 17:57:01 105

原创 PAT 甲级 1024 (Palindromic Number)

PAT 甲级 1024题目要求翻译代码思路题目要求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 numbers are palindromic numbers.Non-palindromic numbers can

2020-09-12 17:13:39 177

原创 PAT 甲级 1023(Have Fun with Numbers)

PAT 甲级 1023题目要求翻译代码思路题目要求Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers f

2020-09-12 11:15:06 213

原创 PAT 甲级 1022(Digital Library)

PAT 甲级 1022题目要求翻译代码思路题目要求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 an unique 7-digit number as its ID. Given any query fro

2020-09-11 23:46:26 195

原创 PAT 甲级 1021(Deepest Root )

PAT 甲级 1021题目要求翻译代码思路题目要求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.I

2020-09-11 22:35:19 296

原创 PAT 甲级 1020(Tree Traversals )

PAT 甲级 1020题目要求翻译代码思路题目要求Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the corresponding binary tree.Input

2020-09-11 15:41:00 117

原创 PAT 甲级 1019(General Palindromic Number)

PAT 甲级 1019题目要求翻译代码思路题目要求翻译判断转换进制后的数是不是回文代码#include<iostream>#include<vector>using namespace std;vector<int> v;bool transfor(int n,int b){ v.clear(); do{ v.push_back(n%b); n /=b; }while(n!=0);//“除基取余

2020-09-11 10:13:40 146

原创 PAT 甲级 1017(Queueing at Bank)

PAT 甲级 1017题目要求翻译代码思路题目要求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 in line behind the yellow line, until it is his/her turn

2020-09-10 19:26:08 97

原创 力扣(C++)139 单词拆分

力扣 139题目要求代码思路题目要求给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,判定 s 是否可以被空格拆分为一个或多个在字典中出现的单词。说明:拆分时可以重复使用字典中的单词。你可以假设字典中没有重复的单词。示例 1:输入: s = “leetcode”, wordDict = [“leet”, “code”]输出: true解释: 返回 true 因为 “leetcode” 可以被拆分成 “leet code”。示例 2:输入: s = “applepe

2020-07-09 20:29:39 586

原创 力扣(C++)678 有效的括号字符串

力扣 678题目要求代码思路题目要求给定一个只包含三种字符的字符串:( ,) 和 *,写一个函数来检验这个字符串是否为有效字符串。有效字符串具有如下规则:任何左括号 ( 必须有相应的右括号 )。任何右括号 ) 必须有相应的左括号 ( 。左括号 ( 必须在对应的右括号之前 )。可以被视为单个右括号 ) ,或单个左括号 ( ,或一个空字符串。一个空字符串也被视为有效字符串。示例 1:输入: “()”输出: True示例 2:输入: “(*)”输出: True示例 3:输入: “

2020-07-09 19:27:15 592

原创 DFS无向图找最短路径并打印

题目建立一个无向图,输入起点和终点,搜索最短路径并打印。Example:Input:41 21 31 42 511 5Output:2125代码#include<iostream>#include<vector>using namespace std;vector<int> path,tmp;vector<int> v[1000];bool visited[1000];int minn,start,endi;;v

2020-07-05 09:56:08 889

原创 PAT 甲级 1018(Public Bike Management)

PAT 甲级 1016题目要求翻译代码题目要求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 the call is made. When a customer starts connecting a

2020-07-02 23:57:54 156

原创 PAT 甲级 1015(Reversible Primes)

PAT 甲级 1015题目要求翻译代码思路题目要求A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a prime.Now given any two positi

2020-06-24 13:56:27 265

原创 PAT 乙级 1050(螺旋矩阵 )

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

2020-06-24 11:21:21 126

原创 PAT 乙级 1049(数列的片段和 )

PAT 乙级 1049题目要求代码思路题目要求给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段。例如,给定数列 { 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 个片段。给定正整数数列,求出全部片段包含的所有的数之和。如本例中 10 个片段总和是 0.1 +

2020-05-15 10:33:40 277

原创 PAT 乙级 1048(数字加密)

PAT 乙级 1048题目要求代码思路题目要求本题要求实现一种数字加密方法。首先固定一个加密用正整数 A,对任一正整数 B,将其每 1 位数字与 A 的对应位置上的数字进行以下运算:对奇数位,对应位的数字相加后对 13 取余——这里用 J 代表 10、Q 代表 11、K 代表 12;对偶数位,用 B 的数字减去 A 的数字,若结果为负数,则再加 10。这里令个位为第 1 位。输入格式:输入在一行中依次给出 A 和 B,均为不超过 100 位的正整数,其间以空格分隔。输出格式:在一行中输出加密后的

2020-05-15 09:19:51 174

原创 全球某工商C++上机题(已知某基类已提供Delta算法...)

题目要求已知某基类已提供求Δ\DeltaΔ的算法,编程用派生类继承该算法并求一元二次方程的实根和虚根(要求有出错提示)。代码#include<iostream>#include<cmath>using namespace std;class CBase{private: float a,b,c,d;public: float delta(float a,float b,float c) { d=b*b-4*a*c;

2020-05-12 12:12:28 728 4

原创 全球某工商C++上机题(创键一个Cdate类....)

题目要求创键一个Cdate类,该类中有y(年)、m(月)、d(日)数据成员及初始化这些数据的构造函数和设置该日期的外联成员函数和显示日期的友元函数。完成在主程序中初始化日期、设置键入的日期和显示该日期的操作。代码#include<iostream>using namespace std;class Cdate{private: int y,m,d;public: Cdate(){ y=2020; m=5; d=1

2020-05-12 12:07:15 828

原创 PAT 甲级 1014(Waiting in Line)

PAT 甲级 1014题目要求翻译代码思路题目要求Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:The space inside the yellow line in fro

2020-05-11 15:16:07 156

原创 PAT 乙级 1047(编程团体赛)

PAT 乙级 1047题目要求代码思路题目要求编程团体赛的规则为:每个参赛队由若干队员组成;所有队员独立比赛;参赛队的成绩为所有队员的成绩和;成绩最高的队获胜。现给定所有队员的比赛成绩,请你编写程序找出冠军队。输入格式:输入第一行给出一个正整数 N(≤10​4​​ ),即所有参赛队员总数。随后 N 行,每行给出一位队员的成绩,格式为:队伍编号-队员编号 成绩,其中队伍编号为 1 到 1000 的正整数,队员编号为 1 到 10 的正整数,成绩为 0 到 100 的整数。输出格式:在一行中输

2020-05-10 14:33:44 155

原创 PAT 乙级 1046(划拳)

PAT 乙级 1045题目要求代码思路题目要求划拳是古老中国酒文化的一个有趣的组成部分。酒桌上两人划拳的方法为:每人口中喊出一个数字,同时用手比划出一个数字。如果谁比划出的数字正好等于两人喊出的数字之和,谁就赢了,输家罚一杯酒。两人同赢或两人同输则继续下一轮,直到唯一的赢家出现。下面给出甲、乙两人的划拳记录,请你统计他们最后分别喝了多少杯酒。输入格式:输入第一行先给出一个正整数 N(≤100),随后 N 行,每行给出一轮划拳的记录,格式为:甲喊 甲划 乙喊 乙划其中喊是喊出的数字,划是划出的数

2020-05-10 14:01:34 501

原创 PAT 乙级 1045(快速排序)(有坑点:测试点2)

PAT 乙级 1045题目要求代码思路题目要求著名的快速排序算法里有一个经典的划分过程:我们通常采用某种方法取一个元素作为主元,通过交换,把比主元小的元素放到它的左边,比主元大的元素放到它的右边。 给定划分后的 N 个互不相同的正整数的排列,请问有多少个元素可能是划分前选取的主元?例如给定 N=5N = 5N=5, 排列是1、3、2、4、5。则:1 的左边没有元素,右边的元素都比它大,所以它可能是主元;尽管 3 的左边元素都比它小,但其右边的 2 比它小,所以它不能是主元;尽管 2 的右边元素都

2020-05-10 11:20:03 408

原创 PAT 乙级 1044( 火星数字)

PAT 乙级 1044题目要求代码思路题目要求火星人是以 13 进制计数的:地球人的 0 被火星人称为 tret。地球人数字 1 到 12 的火星文分别为:jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec。火星人将进位以后的 12 个高位数字分别称为:tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou。例如地球人的数字 29 翻译成火星文就是 hel mar;而火

2020-05-10 08:48:09 143

原创 PAT 甲级 1013(Battle Over Cities )

PAT 甲级 1013题目要求翻译代码思路题目要求翻译在战争中,所有的城市都通过高速公路连接在一起,这一点是至关重要的。如果一个城市被敌人占领了,那么所有连接这个城市的高速公路都会被封闭。我们必须马上知道为了使得余下的城市保持连接状态,我们是否需要修建其他的高速公路。给你一张城市地图,上面标识出了所有余下的高速公路,你需要快速说出需要修建的高速公路的数量。举个例子,如果我们有3座城市,2条高速公路分别连接city1-city2、city1-city3。如果city1被敌人占领了,我们就需要修建一条

2020-05-09 23:00:04 155

空空如也

空空如也

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

TA关注的人

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