- 博客(221)
- 收藏
- 关注
原创 LeetCode 7. 整数反转
给你一个 32 位的有符号整数 x ,返回将 x 中的数字部分反转后的结果。如果反转后整数超过 32 位的有符号整数的范围 [−231231− 1] ,就返回 0。假设环境不允许存储 64 位整数(有符号或无符号)。
2025-10-08 16:10:52
223
原创 LeetCode 4. 寻找两个正序数组的中位数
给定两个大小分别为m和n的正序(从小到大)数组nums1和nums2。请你找出并返回这两个正序数组的 中位数。算法的时间复杂度应该为。
2025-10-07 14:31:20
114
原创 Manjaro 配置 Docker 详细步骤
Docker 是一个开源的应用程序容器化平台,它允许你在独立的容器中打包、分发和运行应用。Docker Desktop 是一个官方的 Docker 应用程序,提供了一个 GUI 界面,帮助用户管理 Docker 容器。
2025-09-30 16:20:12
485
原创 Manjaro 配置 FFmpeg
FFmpeg 相当于多媒体处理的瑞士军刀。FFmpeg 是一个开源项目,由一套庞大的工具集组成,用于处理几乎所有格式的音频、视频和其他多媒体文件。它是一个强大的命令行工具和程序库集合,是许多主流视频应用和流媒体服务的幕后英雄。
2025-09-29 19:40:51
204
原创 LeetCode 2. 两数相加
给你两个 非空 的链表,表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的,并且每个节点只能存储 一位 数字。请你将两个数相加,并以相同形式返回一个表示和的链表。你可以假设除了数字 0 之外,这两个数都不会以 0 开头。
2025-09-28 19:11:21
206
原创 PAT乙级 1050 螺旋矩阵
本题要求将给定的 N 个正整数按非递增的顺序,填入“螺旋矩阵”。所谓“螺旋矩阵”,是指从左上角第 1 个格子开始,按顺时针螺旋方向填充。要求矩阵的规模为 m 行 n 列,满足条件:m×n 等于 N;m≥n;且 m−n 取所有可能值中的最小值。
2025-09-28 18:37:42
231
原创 PAT甲级 1045 Favorite Color Stripe
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 pieces and sewing the remaining parts together to form her favorite color stripe.It is said t
2025-09-26 00:35:58
1012
原创 PAT乙级 1063 计算谱半径
在数学中,矩阵的“谱半径”是指其特征值的模集合的上确界。换言之,对于给定的 n 个复数空间的特征值 {a1a_1a1+b1b_1b1iii,⋯,ana_nan+bnb_nbniii},它们的模为实部与虚部的平方和的开方,而“谱半径”就是最大模。现在给定一些复数空间的特征值,请你计算并输出这些特征值的谱半径。
2025-09-26 00:35:41
377
原创 PAT乙级 1066 图像过滤
图像过滤是把图像中不重要的像素都染成背景色,使得重要部分被凸显出来。现给定一幅黑白图像,要求你将灰度值位于某指定区间内的所有像素颜色都用一种指定的颜色替换。
2025-09-26 00:35:15
134
原创 PAT乙级 1071 小赌怡情
常言道“小赌怡情”。这是一个很简单的小游戏:首先由计算机给出第一个整数;然后玩家下注赌第二个整数将会比第一个数大还是小;玩家下注 t 个筹码后,计算机给出第二个数。若玩家猜对了,则系统奖励玩家 t 个筹码;否则扣除玩家 t 个筹码。注意:玩家下注的筹码数不能超过自己帐户上拥有的筹码数。当玩家输光了全部筹码后,游戏就结束。
2025-09-26 00:35:03
223
原创 PAT乙级 1072 开学寄语
下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其 QQ,封其电脑,夺其手机,收其 ipad,断其 wifi,使其百无聊赖,然后,净面、理发、整衣,然后思过、读书、锻炼、明智、开悟、精进。而后必成大器也!本题要求你写个程序帮助这所学校的老师检查所有学生的物品,以助其成大器。
2025-09-26 00:34:53
151
原创 PAT甲级 1076 Forwards on Weibo
Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a user makes a post on Weibo, all his/her followers can vi
2025-09-26 00:34:37
558
原创 PAT乙级 1076 Wifi密码
下面是微博上流传的一张照片:“各位亲爱的同学们,鉴于大家有时需要使用 wifi,又怕耽误亲们的学习,现将 wifi 密码设置为下列数学题答案:A-1;B-2;C-3;D-4;请同学们自己作答,每两日一换。!~”—— 老师们为了促进学生学习也是拼了…… 本题就要求你写程序把一系列题目的答案按照卷子上给出的对应关系翻译成 wifi 的密码。这里简单假设每道选择题都有 4 个选项,有且只有 1 个正确答案。
2025-09-26 00:34:25
336
原创 PAT乙级 1037 在霍格沃茨找零钱
如果你是哈利·波特迷,你会知道魔法世界有它自己的货币系统 —— 就如海格告诉哈利的:“十七个银西可(Sickle)兑一个加隆(Galleon),二十九个纳特(Knut)兑一个西可,很容易。”现在,给定哈利应付的价钱 P 和他实付的钱 A,你的任务是写一个程序来计算他应该被找的零钱。
2025-09-26 00:34:12
316
原创 PAT乙级 1036 跟奥巴马一起编程
美国总统奥巴马不仅呼吁所有人都学习编程,甚至以身作则编写代码,成为美国历史上首位编写计算机代码的总统。2014 年底,为庆祝“计算机科学教育周”正式启动,奥巴马编写了很简单的计算机代码:在屏幕上画一个正方形。现在你也跟他一起画吧!
2025-09-26 00:34:04
234
原创 PAT乙级 1027 打印沙漏
本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印****************所谓“沙漏形状”,是指每行输出奇数个符号;各行符号中心对齐;相邻两行符号数差2;符号数先从大到小顺序递减到1,再从小到大顺序递增;首尾符号数相等。给定任意N个符号,不一定能正好组成一个沙漏。要求打印出的沙漏能用掉尽可能多的符号。
2025-09-26 00:33:55
217
原创 PAT乙级 1026 程序运行时间
要获得一个 C 语言程序的运行时间,常用的方法是调用头文件 time.h,其中提供了 clock() 函数,可以捕捉从程序开始运行到 clock() 被调用时所耗费的时间。这个时间单位是 clock tick,即“时钟打点”。同时还有一个常数 CLK_TCK,给出了机器时钟每秒所走的时钟打点数。于是为了获得一个函数 f 的运行时间,我们只要在调用 f 之前先调用 clock(),获得一个时钟打点数 C1;在 f 执行完成后再调用 clock(),获得另一个时钟打点数 C2;
2025-09-25 12:27:41
164
原创 PAT甲级 1089 Insert or Merge
According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list, and
2025-09-25 09:24:09
691
原创 PAT甲级 1153 Decode Registration Card of PAT 测试点3过不去
A registration card number of PAT consists of 4 parts:Now given a set of registration card numbers and the scores of the card owners, you are supposed to output the various statistics according to the given queries.Each input file contains one test case.
2025-09-25 09:23:27
343
原创 PAT乙级 1003 我要通过!
答案正确”是自动判题系统给出的最令人欢喜的回复。本题属于 PAT 的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”。字符串中必须仅有 P、 A、 T这三种字符,不可以包含其它字符;任意形如 xPATx 的字符串都可以获得“答案正确”,其中 x 或者是空字符串,或者是仅由字母 A 组成的字符串;如果 aPbTc 是正确的,那么 aPbATca 也是正确的,其中 a、 b、 c 均或者是空字符串,或者是仅由字母 A 组成的字符串。
2025-09-25 09:23:18
117
原创 PAT甲级 1004 Counting Leaves
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Each input file contains one test case. Each case starts with a line containing 0<N<100, the number of nodes in a tree, and M (<N), th
2025-09-25 09:23:01
292
原创 PAT甲级 1009 Product of Polynomials
This time, you are supposed to find A×B where A and B are two polynomials.Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial:K N1N_1N1 aN1N_1N1 N2N_2N2 aN2N_2N2 … NKN_KNK a
2025-09-25 09:22:44
321
原创 PAT甲级 1010 Radix
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive integers N1N_1N1 and N2N_2N2, your task is to find the ra
2025-09-25 09:18:58
432
原创 PAT甲级 1013 Battle Over Cities
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 must know immediately if we need to repair any other highways to keep the rest of the c
2025-09-25 09:18:49
639
原创 PAT甲级 1014 Waiting in Line
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:Now given the processing time of each customer, you are supposed t
2025-09-25 09:18:34
547
原创 PAT甲级 1016 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 ti
2025-09-25 09:18:20
622
原创 PAT甲级 1090 Highest Price in Supply Chain
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.
2025-09-25 09:18:00
837
原创 PAT甲级 1017 Queueing at Bank
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 to be served and there is a
2025-09-25 09:17:42
609
原创 PAT乙级 1018 锤子剪刀布
大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如图所示:现给出两人的交锋记录,请统计双方的胜、平、负次数,并且给出双方分别出什么手势的胜算最大。
2025-09-25 09:17:28
266
原创 PAT乙级 1021 个位数统计
给定一个 k 位整数 N=dk−1d_{k−1}dk−110k−110^{k−1}10k−1+⋯+d1d_1d110110^1101d0d_0d0 (0≤did_ididkd_kdk−1>0),请编写程序统计每种不同的个位数字出现的次数。例如:给定 N=100311,则有 2 个 0,3 个 1,和 1 个 3。
2025-09-25 09:17:15
324
原创 PAT甲级 1125 Chain the Ropes
Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one piece, as shown by the figure. The resulting chain will be treated as another segment of rope and can be
2025-09-24 09:45:35
338
原创 PAT甲级 1124 Raffle for Weibo Followers
John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo – that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now you are supposed to help him generate th
2025-09-24 09:45:21
376
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅