贺巩山的博客

没有伞的孩子更要努力奔跑


  • 首页

  • 文件系统

  • Linux运维

  • 剑指Offer

  • LeetCode题解

  • PAT甲级题解

  • PAT乙级题解

  • CCF CSP题解

  • 分类

  • 标签

  • 归档

  • 书单

  • 关于

  • 搜索

2019 CCF CCSP分区赛折戟而归

发表于 2019-05-18 | 更新于 2019-05-18 | 分类于 生活
字数统计: 1.2k

湖南大学

阅读全文 »

PAT甲级 1077.Kuchiguse (20 分)

发表于 2019-05-16 | 更新于 2019-05-16 | 分类于 pat甲级
字数统计: 482

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 Anime and Manga. For example, the artificial sentence ending particle “nyan~” is often used as a stereotype for characters with a cat-like personality:

  • Itai nyan~ (It hurts, nyan~)
  • Ninjin wa iyada nyan~ (I hate carrots, nyan~)

Now given a few lines spoken by the same character, can you find her Kuchiguse?

阅读全文 »

PAT甲级 1035.Password (20 分)

发表于 2019-05-16 | 更新于 2019-05-16 | 分类于 pat甲级
字数统计: 602

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 solution is to replace 1(one) by @, 0 (zero) by %, l by L, and O by o. Now it is your job to write a program to check the accounts generated by the judge, and to help the juge modify the confusing passwords.

阅读全文 »

LeetCode 328.奇偶链表

发表于 2019-05-10 | 更新于 2019-05-10 | 分类于 leetcode
字数统计: 686

题目描述

给定一个单链表,把所有的奇数节点和偶数节点分别排在一起。请注意,这里的奇数节点和偶数节点指的是节点编号的奇偶性,而不是节点的值的奇偶性。

请尝试使用原地算法完成。你的算法的空间复杂度应为 O(1),时间复杂度应为 O(nodes),nodes 为节点总数。

示例 1:

1
2
输入: 1->2->3->4->5->NULL
输出: 1->3->5->2->4->NULL

示例 2:

1
2
输入: 2->1->3->5->6->4->7->NULL 
输出: 2->3->6->7->1->5->4->NULL

说明:

  • 应当保持奇数节点和偶数节点的相对顺序。
  • 链表的第一个节点视为奇数节点,第二个节点视为偶数节点,以此类推。
阅读全文 »

LeetCode 203.移除链表元素

发表于 2019-05-08 | 更新于 2019-05-08 | 分类于 leetcode
字数统计: 304

题目描述

删除链表中等于给定值 val 的所有节点。

示例:

1
2
输入: 1->2->6->3->4->5->6, val = 6
输出: 1->2->3->4->5
阅读全文 »

PAT甲级 1005.Spell It Right (20 分)

发表于 2019-05-08 | 更新于 2019-05-08 | 分类于 pat甲级
字数统计: 401

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.

阅读全文 »

PAT甲级 1001.A+B Format (20 分)

发表于 2019-05-07 | 更新于 2019-05-07 | 分类于 pat甲级
字数统计: 244

Calculate a+b and output the sum in standard format – that is, the digits must be separated into groups of three by commas (unless there are less than four digits).

阅读全文 »

PAT乙级 1048.数字加密 (20 分)

发表于 2019-05-07 | 更新于 2019-05-07 | 分类于 pat乙级
字数统计: 472

本题要求实现一种数字加密方法。首先固定一个加密用正整数 A,对任一正整数 B,将其每 1 位数字与 A 的对应位置上的数字进行以下运算:对奇数位,对应位的数字相加后对 13 取余——这里用 J 代表 10、Q 代表 11、K 代表 12;对偶数位,用 B 的数字减去 A 的数字,若结果为负数,则再加 10。这里令个位为第 1 位。

阅读全文 »

PAT乙级 1024.科学计数法/PAT甲级 1073.Scientific Notation (20 分)

发表于 2019-05-05 | 更新于 2019-05-23 | 分类于 pat乙级 , pat甲级
字数统计: 717

科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式 [+-][1-9].[0-9]+E[+-][0-9]+,即数字的整数部分只有 1 位,小数部分至少有 1 位,该数字及其指数部分的正负号即使对正数也必定明确给出。

现以科学计数法的格式给出实数 A,请编写程序按普通数字表示法输出 A,并保证所有有效位都被保留。

阅读全文 »

LeetCode 264.丑数 II

发表于 2019-05-03 | 更新于 2019-05-03 | 分类于 leetcode
字数统计: 356

题目描述

编写一个程序,找出第 n 个丑数。

丑数就是只包含质因数 2, 3, 5 的正整数。

示例:

1
2
3
输入: n = 10
输出: 12
解释: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 是前 10 个丑数。

说明:

  1. 1 是丑数。
  2. n 不超过1690。
阅读全文 »
1…373839…49
Gongshan He

Gongshan He

490 日志
62 分类
89 标签
GitHub 微博 知乎 Linkedin E-Mail
友情链接
  • 卢明冬的博客
  • lipixun
  • 柳婼 の blog
  • 心灵港
  • Liudeyin
© 2016 — 2023 Gongshan He
访问人数 总访问量 次