自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 pbrt-v4 windows编译失败指南

cpu下编译成功很容易,但是gpu有点麻烦,主要有下面几个坑。

2024-03-29 13:25:37 322

原创 Zotero 7 安装并彻底解决“无法安装插件。它可能无法与该版本的 Zotero 兼容“。以及解决“此翻译引擎不可用,可能是密钥错误“的问题

Zotero 7 安装并彻底解决"无法安装插件。它可能无法与该版本的 Zotero 兼容"。以及解决"此翻译引擎不可用,可能是密钥错误"的问题

2023-12-19 13:54:52 8008 1

原创 PAT-1037 Magic Coupon

1037 Magic Couponpart 5, 5.1题意理解给出优惠卷数Nc,和对应的价格,产品Np和对应的价格,一章优惠卷数任意对应一个产品,尽可能地赚钱Sample Input:41 2 4 -147 6 -2 -3Sample Output:43自己解法两个数列按正负分成四个数列,绝对值越大越靠前然后从大到小,正乘正,负乘负严格来说可以算是贪心#include <iostream>using namespace std;#incl

2022-03-09 09:34:50 133

原创 PAT-1030 Travel Plan

1030 Travel Planpart 5, 5.0题意理解给出城市数量N,城市之间的路线M条,开始城市S,结束城市D,然后依次M条City1 City2 Distance Cost,给出最短路径(相同最短路径下最短时间),路径,和所花费的时间INPUT4 5 0 30 1 1 201 3 2 300 3 4 100 2 2 202 3 1 20OUTPUT0 2 3 3 40自己解法基本的Dijstra算法套路#include <iostream&gt

2022-03-07 15:12:51 132

原创 PAT-1034 Head of a Gang

1034 Head of a Gangpart 4, 4.4自己解法最后有一个按字母排序输出,用map存储,map会自动排序本来有一个段错误,第10行由1001改成10001就过了(有n条通话记录(n<=1000)但是最多会有2000个结点)#include <iostream>using namespace std;#include <map>#include <vector>#include <algorithm>int

2022-03-03 17:53:55 397

原创 PAT-1102 Invert a Binary Tree

1102 Invert a Binary Treepart 4, 4.3自己解法多熟悉熟悉各种遍历就行hhh,注意levelOrder的性质就行#include <iostream>using namespace std;#include <vector>#include <map>#include <algorithm>struct node{ int left = -1; int right = -1;} n

2022-03-02 21:15:18 511

原创 PAT-1106 Lowest Price in Supply Chain

1106 Lowest Price in Supply Chainpart 4, 4.3自己解法和1090一个模子#include <iostream>using namespace std;#include <vector>#include <math.h>int minDepth = 1000000, count = 0;vector<int> v[100000];void bfs(int index, int depth)

2022-03-01 21:09:17 78

原创 PAT-1094 The Largest Generation

1094 The Largest Generationpart 4, 4.3自己解法dfs和bfs都可以做#include <iostream>using namespace std;#include <vector>int count[100];vector<int> v[101];void bfs(int index, int depth){ if (count[depth] == -1) count[depth

2022-03-01 20:56:22 70

原创 PAT-1079 Total Sales of Supply Chain

1079 Total Sales of Supply Chainpart 4, 4.3自己解法理解好题意就不难#include <iostream>using namespace std;#include <vector>#include <math.h>double P, r;double price = 0;vector<int> v[100000];vector<int> retailsPrice(100000

2022-03-01 20:09:46 56

原创 PAT-1074 Reversing Linked List

1074 Reversing Linked Listpart 4, 4.1自己解法链表有套路的使用struct存储地址数据如果要排序,struct里面需要加一个address的地址属性,否则用下标标识就好了输入的node很有可能不合格,要先跑一遍链表,用struct中的flag标识关键在这个 cmp 排序函数#include <iostream>using namespace std;#include <algorithm>int K, ct =

2022-03-01 12:52:11 128

原创 PAT-1047 Student List for Course

1047 Student List for Coursepart 4, 4.0自己解法第二个WA,最后一个TO#include <iostream>using namespace std;#include <vector>#include <map>#include <algorithm>vector<string> sName;bool cmp(int a, int b){ return sName[a]

2022-02-28 16:36:43 67

原创 PAT-1063 Set Similarity

1063 Set Similaritypart 4, 4.0自己解法一开始第二个循环里面写了三个循环,然后发现最后一个过不了,就将三个循环优化为一个循环,就过了#include <iostream>using namespace std;#include <vector>#include <map>#include <algorithm>int main(){ int N, M; cin >> N;

2022-02-28 15:26:59 119

原创 PAT-1039 Course List for Student

1039 Course List for Studentpart 4, 4.0自己解法#include <iostream>using namespace std;#include <vector>#include <map>#include <algorithm>int main(){ int N, K; cin >> N >> K; map<string, vector<i

2022-02-28 15:26:26 139

原创 PAT-1101 Quick Sort

1101 Quick Sortpart 3, 3.5自己解法pivot 支点,中心点,基准点;题意:找出一个序列中有多少个点,使得左边全部小于它,右边全部大于它我的思路是,生成两个数列,分别代表当前值,之前的左边最大和右边最小,只要当前的数小于左边最大和右边最小即可#include <iostream>using namespace std;#include <vector>#include <algorithm>int main(){

2022-02-26 23:46:30 87

原创 PAT-1093 Count PAT‘s

1093 Count PAT’spart 3, 3.5自己解法本来说是啥活用递归,但是我不懂为啥要用递归hhh,我的思路和柳神一模一样,他的还要更简洁#include <iostream>using namespace std;#include <vector>#include <algorithm>int main(){ string s; cin >> s; long long count = 0, cP

2022-02-26 22:21:37 116

原创 PAT-1088 Rational Arithmetic

1088 Rational Arithmeticpart 3, 3.4自己解法rational numbers:有理数;sum, difference, product and quotient:加减乘除;a pair of parentheses:一对括号见到说 in the rang of long int(2322^{32}232 和 101010^{10}1010),就使用 long long题目看起来复杂,实则逻辑很清晰#include <iostream>usi

2022-02-26 20:56:17 121

原创 PAT-1081 Rational Sum

1081 Rational Sumpart 3, 3.4自己解法numerator 分子;denominator 分母这里并没有用到辗转相除法关键是 line 42 ,每隔一段时间就约分#include <iostream>using namespace std;#include <string.h>int d[100000];void getF(){ memset(d, 1, sizeof(d)); d[0] = 0; d[

2022-02-26 19:57:52 442

原创 PAT-1023 Have Fun with Numbers

1023 Have Fun with Numberspart 3, 3.1自己解法理解题意permutation:排列注意溢出照样输出#include <iostream>using namespace std;#include <algorithm>int main(){ string n, m = "", x; cin >> n; string c = n; int s = 0, d, flag =

2022-02-25 20:01:21 198

原创 PAT-1078 Hashing

1078 Hashingpart 3, 3.1自己解法注意最后一个点需要处理二次探测#include <iostream>using namespace std;#include <vector>#include <algorithm>bool isPrime(int m){ if (m <= 1) return false; for (int i = 2; i < m; i++) i

2022-02-25 19:22:03 243

原创 PAT-1015 Reversible Primes

1015 Reversible Primespart 3, 3.1自己解法1不是质数#include <iostream>using namespace std;#include <string>#include <algorithm>#include <math.h>string transfrom(int N, int D){ string m = ""; while (N >= D) {

2022-02-25 15:51:38 212

原创 PAT-1104 Sum of Number Segments

1104 Sum of Number Segmentspart 3, 3.0自己解法以后WA如果没有明显的逻辑错误就很有可能是类型错了long %ldlong long %lldfloat %fdouble %f 在C99及C++中,可以用%lflong double %Lf Linux可以直接用,Windows要加宏定义(详见下文)char %cchar*(char[]) %sstring(C++类型) %s printf("%s",string.c_str());lo

2022-02-24 19:15:45 103

原创 PAT-1008 Elevator

1008 Elevatorpart 3, 3.0自己解法较为简单#include <iostream>using namespace std;#include <vector>int main(){ int n, e; cin >> n; int d[100]; int s = 0, cost = 0; for (int i = 0; i < n; i++) { cin &gt

2022-02-24 10:32:35 161

原创 PAT-1029 Median

1029 Medianpart 2, 2.3自己解法第20行的判断条件搞清楚就行#include <iostream>using namespace std;#include <vector>int main(){ int n1; cin >> n1; int s1[200000]; for (int i = 0; i < n1; i++) cin >> s1[i]; in

2022-02-23 21:08:27 98

原创 PAT-1092 To Buy or Not to Buy

1092 To Buy or Not to Buypart 2, 2.2自己解法#include <iostream>using namespace std;int main(){ string a, b; cin >> a >> b; int a_size = a.size(); int b_size = b.size(); int h = 0, j = 0; for (int i = 0; i <

2022-02-23 20:09:00 62

原创 PAT-1084 Broken Keyboard

1084 Broken Keyboardpart 2, 2.2自己解法PAT 里面散列的题目都还挺简单的#include <iostream>using namespace std;#include <algorithm>int main(){ string s, v; cin >> s >> v; transform(s.begin(), s.end(), s.begin(), ::toupper);

2022-02-23 20:08:22 79

原创 PAT-1050 String Subtraction

1050 String Subtractionpart 2, 2.2自己解法很多时候,STL的算法已经足够快了#include <iostream>using namespace std;#include <string>int main(){ string s1, s2; getline(cin, s1); getline(cin, s2); int s1_size = s1.size(); int s2_size

2022-02-22 16:31:52 230

原创 PAT-1041 Be Unique

1041 Be Uniquepart 2, 2.2自己解法注意看好输入的数字的范围,下面第10行写成10000就会有段错误#include <iostream>using namespace std;#include <vector>#include <string.h>int main(){ int N; cin >> N; int d[10001]; memset(d, 0, 10001);

2022-02-22 16:17:41 244

原创 PAT-1083 List Grades

1083 List Gradespart 2, 2.1自己解法太简单了,10分钟不到就好了#include <iostream>using namespace std;#include <vector>#include <algorithm>struct stu{ string name, ID; int grade;};bool cmp(stu a, stu b){ return a.grade > b.

2022-02-15 19:42:02 251

原创 PAT-1080 Graduate Admission

1080 Graduate Admissionpart 2, 2.1自己解法当作是高考填志愿,就很好理解题目#include <iostream>using namespace std;#include <vector>#include <algorithm>struct applicant{ int seq; int GE, GI; double final; int choices[5] = {-1, -1,

2022-02-15 13:13:42 66

原创 PAT-1075 PAT Judge

1075 PAT Judgepart 2, 2.1自己解法(未全对)看了柳神的,还是不太清楚第四个测试哪错了#include <iostream>using namespace std;#include <vector>#include <algorithm>// K <= 5int partial_score[5];struct person{ int uid = -1; int rank = 0, total_s

2022-02-13 00:00:37 140

原创 PAT-1062 Talent and Virtue

1062 Talent and Virtuepart 2, 2.1自己解法认真读题!(惨痛教训)#include <iostream>using namespace std;#include <vector>#include <algorithm>class person{public: person(int ID, int V, int T, int H) { this->ID = ID;

2022-02-12 20:33:44 520

原创 PAT-1055 The World’s Richest

1055 The World’s Richestpart 2, 2.1自己解法2 TO属实是被柳神的分析击中了N 是 10510^5105,而 M 小于10310^3103,因此这里主要是排序慢,所以下面这里我即使用了二分查找也很慢。#include <iostream>using namespace std;#include <vector>#include <algorithm>#include <math.h>struct

2022-02-12 17:14:36 386

原创 PAT-1028 List Sorting

1028 List Sortingpart 2, 2.1自己解法目前遇到的最简单的排序题#include <iostream>using namespace std;#include <vector>#include <algorithm>int C;struct student{ int ID; string name; int grades;};bool cmpC1(student a, student b)

2022-02-10 19:43:11 335

原创 PAT-1025 PAT Ranking

1025 PAT Rankingpart 2, 2.1自己解法(未全对)4 WA,但是牛客网中可以全对#include <iostream>using namespace std;#include <vector>#include <map>#include <algorithm>struct test{ long long number; int grade; int loc; int rank[

2022-02-10 19:20:50 272

原创 PAT-1048 Find Coins

1048 Find Coinspart 2, 2.0自己解法(未全对)2 WA 3,4 TO可恶,直接用find太慢了#include <iostream>using namespace std;#include <vector>#include <algorithm>int main(){ int N, M; cin >> N >> M; int V1, V2; vector&

2022-02-09 20:57:36 687

原创 PAT-1044 Shopping in Mars

1044 Shopping in Marspart 2, 2.0自己解法(滑动窗口)2,5 TO 4 WA -> 算法不够高效#include <iostream>using namespace std;#include <vector>#define maxn 100000int d[maxn];int main(){ int N, M; cin >> N >> M; int nearliest =

2022-02-08 10:23:00 76

原创 PAT-1010 Radix

1010 Radixpart 2, 2.0自己解法(二分法)3,4,5,7,10,11 WA -> 只有tag所指定到的那个数有进制2-36的限制,而另一个数的进制是不限的1 WA, 7 TO -> 查找算法不够高效6,8,10,12,13 WA -> 二分法未考虑转换为10进制的数会溢出,最终的数为负数(第47行)注意有可能产生溢出,使用long long类型#include <iostream>using namespace std;#includ

2022-02-07 23:15:32 95

原创 PAT-1031 Hello World for U

1031 Hello World for Upart 1, 1.5自己解法注意字符数组的初始化,如果不是用memset初始化,而是使用char c[30][30] = {’ '}的话,PAT测试会报错#include <iostream>using namespace std;#include <string.h>int main(){ string s; cin >> s; int N = s.length();

2022-02-07 17:07:00 67

原创 PAT-1036 Boys vs Girls

1036 Boys vs Girlspart 1, 1.3自己解法#include <iostream>using namespace std;int main(){ int lowM = 10000, hignW = -10000; int ilowM = -1, ihignW = -1, i = 0; string name[1000], ID[1000]; int N; cin >> N; while (N--)

2022-02-07 16:05:37 175

原创 PAT-1011 World Cup Betting

1011 World Cup Bettingpart 1, 1.3自己解法#include <iostream>using namespace std;float getGreat(float a[3]){ char rep[3] = {'W', 'T', 'L'}; float max = 0; int index; for (int i = 0; i < 3; i++) if (a[i] > max)

2022-02-07 15:33:22 192

空空如也

空空如也

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

TA关注的人

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