自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

YSL

努力奋斗!

  • 博客(99)
  • 收藏
  • 关注

原创 1146 Topological Order (25 分)

This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test each of the options.Input Specification:Each input fi

2021-03-13 12:11:22 210

转载 1145 Hashing - Average Search Time (25 分)

/* 题目大意:给定一个序列,用平方探测法解决哈希冲突,然后给出m个数字,如果这个数字不能够被插入就输出”X cannot be inserted.”, 然后输出这m个数字的平均查找时间分析:先找到大于tsize的最小的素数为真正的tsize,然后建立一个tsize长度的数组。首先用平方探测法插入数字a,每次pos = (a + j * j) % tsize,j是从0~tsize-1的数字,如果当前位置可以插入就将a赋值给v[pos],如果一次都没有能够插入成功就输出”X canno

2021-03-08 20:14:27 196

原创 1060 Are They Equal (25 分)

If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×10​5​​ with simple chopping. Now given the number of significant digits on a machine and two float numbers, you

2021-02-20 10:43:13 189

原创 1067 Sort with Swap(0, i) (25 分)

Given any permutation of the numbers {0, 1, 2,…, N-1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2, 1, 3} we may apply the swap operations in the following

2021-02-06 23:57:17 120

原创 1037 Magic Coupon (25 分)

The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product back! What is more, the shop also offers some bonus produ

2021-02-06 16:49:22 84

原创 1033 To Fill or Not to Fill (25 分)

With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are asked to car

2021-02-05 22:53:03 72

原创 1048 Find Coins (25 分)

Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment: for eac

2021-02-04 18:41:18 95

原创 1050 String Subtraction (20 分)

Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1 - S2 for any given strings. However, it might not be that simple to do it fast.Input Specific

2021-02-04 16:06:49 97

原创 1041 Be Unique (20 分)

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,10​4​​ ]. The first one who bets on a unique number wins. For example, if there are 7 p

2021-02-04 15:17:38 84

原创 1095. Cars on Campus (30)-PAT甲级真题(map,排序)

Zhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you are supposed to tell, at any specific time point, the num

2021-02-03 22:13:29 128

原创 1080. Graduate Admission (30)-PAT甲级真题

It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission procedure.Each applicant will have to provide two gra

2021-02-03 15:06:27 92

原创 PAT1075 PAT Judge

The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input file contains one test case. For each case, the first line contai

2021-02-02 17:49:37 127 1

原创 PAT 1083 List Grades

Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades are in a given interval.Input Specification:Each input

2021-01-30 22:13:57 76

原创 PAT 1055 The World‘s Richest

Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world’s wealthiest people. Now you are supposed to simulate this job, but concentrate only on the people in a certain range of ages. That is, given the net wor

2021-01-30 18:39:52 100

原创 PAT 1028 List Sorting

Excel can sort records according to any column. Now you are supposed to imitate this function.InputEach input file contains one test case. For each case, the first line contains two integers N (<=100000) and C, where N is the number of records and C i

2021-01-30 15:34:04 102

原创 PAT Phone Bills

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 long-distance call, the t

2021-01-29 23:03:44 105

原创 PAT 1012 The Best Rank

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 Linear Algebra), and E - English. At the mean time, we encourage students by emphasi

2021-01-25 20:13:45 114

原创 PAT 1082 Read Number in Chinese (25分)

Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output “Fu” first if it is negative. For example, -123456789 is read as “Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu”. Note: zero

2021-01-23 21:39:22 107

原创 PAT 1077 Kuchiguse

The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker’s personality. Such a preference is called “Kuchiguse” and is often exaggerated artistically in Ani

2021-01-23 16:48:18 91

原创 PAT 1035 Password

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) from O (o in uppercase). One

2021-01-22 21:11:30 90

原创 PAT 1005 Spell It Right

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 SpecificationEach input file contains one test case. Each case occupies one line which contains an N (<= 10100).

2021-01-22 17:33:31 68

原创 PAT 1058 A+B in Hogwarts

If you are a fan of Harry Potter, you would know the world of magic has its own currency system – as Hagrid explained it to Harry, “Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it’s easy enough.” Your job is to write a program t

2021-01-22 16:20:23 84

原创 PAT1027 Colors in Mars

1027 Colors in Mars (20分)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

2021-01-22 15:13:34 80

原创 PAT 1019 General Palindromic Number

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.Although palindromic numbers are most often considered

2021-01-21 21:57:49 58

原创 PAT 1031 Hello World for U

Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, “helloworld” can be printed as:h de ll rlowoThat is, the characters must be printed in the original order, starting top-down f

2021-01-21 18:13:07 73

原创 PAT 1036 Boys vs Girls

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 positive integer N, followe

2021-01-21 16:57:34 124

原创 PAT 1006 Sign in and Sign out

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 find the ones who have unlocked and loc

2021-01-21 15:29:35 95

原创 PAT 1011 World Cup Betting

With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting fans were putting their money

2021-01-21 14:12:36 70

原创 PAT 1009 Product of Polynomials

This time, you are supposed to find A*B where A and B 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 polynomial: K N1 aN1 N2 aN2 … NK aNK, where K is

2021-01-14 16:05:24 47

原创 PAT 1002 A+B for Polynomials

This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N1 aN1 N2 aN2 … NK aNK, where K is the number of

2021-01-13 23:19:42 63

原创 PAT 1010 乙级 一元多项式求导

设计函数求一元多项式的导数。(注:xn(n为整数)的一阶导数为n*xn-1。)输入格式以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式以与输入相同的格式输出导数多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。注意“零多项式”的指数和系数都是0,但是表示为“0 0”。输入样例3 4 -5 2 6 1 -2 0输出样例12 3 -10 1 6 0#include <iostream>#include &l

2021-01-13 19:41:52 80

原创 PAT 1046 Shortest Distance

The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file contains one test case. For each case, the first line contains

2021-01-13 15:59:26 68

原创 PAT 1042 Shuffling Machine

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 shuffles, many casinos employ

2021-01-12 22:18:53 52

原创 PAT 1018 锤子剪刀布

大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如图所示:现给出两人的交锋记录,请统计双方的胜、平、负次数,并且给出双方分别出什么手势的胜算最大。输入格式输入第1行给出正整数N(<=105),即双方交锋的次数。随后N行,每行给出一次交锋的信息,即甲、乙双方同时给出的的手势。C代表“锤子”、J代表“剪刀”、B代表“布”,第1个字母代表甲方,第2个代表乙方,中间有1个空格。输出格式输出第1、2行分别给出甲、乙的胜、平、负次数,数字间以1个空格分隔。第3行给出两个字母,分别代表甲、乙获

2021-01-01 21:55:26 157

原创 PAT 数字分类

1012 数字分类 (20分)给定一系列正整数,请按要求对数字进行分类,并输出以下 5 个数字:A​1 = 能被 5 整除的数字中所有偶数的和;A​2 = 将被 5 除后余 1 的数字按给出顺序进行交错求和,即计算 n​1−n2+n​3−n4⋯;A​3 = 被 5 除后余 2 的数字的个数;A4= 被 5 除后余 3 的数字的平均数,精确到小数点后 1 位;A​5​​= 被 5 除后余 4 的数字中最大数字。输入格式:每个输入包含 1 个测试用例。每个测试用例先给出一个不超过 1000 的正

2020-12-30 17:20:08 97

转载 PAT 数组元素循环右移问题(转自柳神)

一个数组A中存有N(N>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(M>=0)个位置,即将A中的数据由(A0 A1……AN-1)变换为(AN-M …… AN-1 A0 A1……AN-M-1)(最后M个数循环移至最前面的M个位置)。如果需要考虑程序移动数据的次数尽量少,要如何设计移动的方法?输入格式每个输入包含一个测试用例,第1行输入N ( 1<=N<=100)、M(M>=0);第2行输入N个整数,之间用空格分隔。输出格式在一行中输出循环右移M位以

2020-12-29 19:56:06 165

原创 PAT 1026 程序运行时间

要获得一个C语言程序的运行时间,常用的方法是调用头文件time.h,其中提供了clock()函数,可以捕捉从程序开始运行到clock()被调用时所耗费的时间。这个时间单位是clock tick,即“时钟打点”。同时还有一个常数CLK_TCK,给出了机器时钟每秒所走的时钟打点数。于是为了获得一个函数f的运行时间,我们只要在调用f之前先调用clock(),获得一个时钟打点数C1;在f执行完成后再调用clock(),获得另一个时钟打点数C2;两次获得的时钟打点数之差(C2-C1)就是f运行所消耗的时钟打点数,再除

2020-12-29 16:36:51 88

原创 PAT 有几个PAT

字符串APPAPT中包含了两个单词“PAT”,其中第一个PAT是第2位( P),第4位(A),第6位(T);第二个PAT是第3位 ( P ),第4位(A),第6位(T)。现给定字符串,问一共可以形成多少个PAT?输入格式输入只有一行,包含一个字符串,长度不超过10^5,只包含P、A、T三种字母。输出格式在一行中输出给定字符串中包含多少个PAT。由于结果可能比较大,只输出对1000000007取余数的结果。输入样例APPAPT输出样例2#include <iostream>#i

2020-12-28 21:06:28 234 1

原创 2-路归并排序(递归)与 (非递归)

2-路归并排序的原理是,将序列两两分组,将序列归并为[n/2]个组,组内单独排序;然后将这些组再两两归并,生成[n/4]个组,组内再单独排序;以此类推,直到只剩下一个组为止。时间复杂度为O(nlogn)。#include <iostream>using namespace std;const int maxn = 100;//归并两个有序区间void merge(int a[], int L1, int R1, int L2, int R2){ int i = L1, j

2020-12-27 16:33:10 481

原创 二分查找 切割问题

工地现有 n 根钢管,第 i 根钢管的长度为 a_i 。现在想用这 n 根钢管来做一个支撑用的柱子。我么可以切割这些钢管成为更短的钢管,但是不能缝合两根钢管。为了安全起见,柱子必须用 至少 k 根长度相同的钢管加上混凝土制成,并且要求钢管长度必须为 整数。这个柱子最高能建成多高(钢管可以有剩余)。输入格式输入第一行一个整数 n,k(1≤n,k≤10000)。接下来一行输入 n 个空格隔开的整数 l_i (1≤ l_i ≤10^8 ),表示每根钢管的长度。输出格式输出最大的高度。样例输入1复制

2020-12-25 16:29:47 333

空空如也

空空如也

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

TA关注的人

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