自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(91)
  • 资源 (1)
  • 收藏
  • 关注

原创 【剑指Offer】66.构建乘积数组(java)

LeetCode/剑指Offer/翻转单词顺序剑指Offer其他题目代码

2020-05-09 20:56:26 211 1

原创 【剑指Offer】58-1.翻转单词顺序(java)

LeetCode/剑指Offer/翻转单词顺序剑指Offer其他题目代码 【思路】1.将整个字符串分成形如"ab"结构的子串。 其中,a是由" "组成的,可以为空;b是由非空格的其他字符组成的,也可以为空。 例如字符串" hello world !!! " 可以分成" ","hello ","world ","!!! "这样四个子串。2.逆序迭代,将每一...

2020-04-27 22:36:21 237

原创 【剑指Offer】39.数组中出现次数超过一半的数字(java)(摩尔投票法)

LeetCode/剑指Offer/ 数组中出现次数超过一半的数字剑指Offer其他题目代码 【分析】关于摩尔投票在知乎上看到了一个非常形象的回答 如何理解摩尔投票算法? - 胡新辰的回答 - 知乎【举例】[1, 2, 3, 2, 2, 2, 5, 4, 2]...

2020-04-26 20:48:58 201

原创 【剑指Offer】29.顺时针打印矩阵(java)

LeetCode/剑指Offer/顺时针打印矩阵 剑指Offer其他题目代码【分析】题目要求逆时针打印全部元素,实际上,数组元素是一圈一圈输出的。想到了丽人行里的小姐姐 ┑( ̄Д  ̄)┍如果要打印一圈元素的话,就要分上下左右四个部分,分别打印,像这样:所有圈都走一遍,就能得到想要的结果,But问题的关键在于如何界定每个部分的开始和结束。为了方便叙述,定义如...

2020-04-24 17:01:20 196

原创 【剑指Offer】04.二维数组中的查找(java)

【分析】现在一看到题,第一反应,暴力求解。虽然不用费脑子,但是时间复杂度高啊。这道在二维数组中查找目标值的题,也可以暴力查找,复杂度O(mn)。但是,这样题目给定的"每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序"就毫无用处了。所以,还是要动动小脑袋。根据题目给定的条件,数组中的值沿主对角线方增大,如图所示:对于(i,j)位置的元素来讲,左上都比它小...

2020-04-22 16:35:46 209

原创 1016 部分A+B (15分)

Github代码(不全,更新中)分析:水题#include <iostream>using namespace std;long long getP(string A, char DA){ int len = A.length(); int P = 0; int temp = DA-'0'; for(int i=0; i<len;...

2020-02-03 11:16:18 105

原创 1015 德才论 (25分)

Github代码(不全,更新中)分析:1.分类:德>=H,才>=H(第一类) 德>=H,才>=L(第二类) 德>=L,才>=L,德>=才(第三类) 德>=L,才>=L(第四类) 其他不满足条件者(第五类)2.排序:第一类>第二类>第三类>第四类>第五类;其次,类内排序按题目给的“总分相同时,按其德分...

2020-02-03 11:04:02 168

原创 1014 福尔摩斯的约会 (20分)

Github代码(不全,更新中)分析:【第一对相同的大写英文字母,包括A-G】,【第二对相同的字符,包括0-9,A-N】,【第三对相同的英文字母,包括大小写】,只要不踩坑,题目还是挺容易的......PS:限定字符的范围时,千万千万不要忘记写等号!!!比如ch<='a',不要写出ch<'a'!!!#include <iostream>#include &lt...

2020-02-03 09:38:32 136

原创 1013 数素数 (20分)

Github代码(不全,更新中)分析:老生常谈的素数题。1.数组开够2.按指定格式输出#include <iostream>#include <cstdio>#include <cmath>using namespace std;int prime[10001];int ind = 0;void getPrime(int N)...

2020-02-02 13:27:19 248

原创 1012 数字分类 (20分)

Github代码(不全,更新中)分析:按题目给的条件,一步步来就好,不难,要仔细#include <iostream>#include <cstdio>using namespace std;int main(){ int N, num; int A1 = 0, A2 = 0, A3 = 0, A5 = 0; double A4 ...

2020-02-02 12:21:20 342

原创 1010 一元多项式求导 (25分)

Github代码(不全,更新中)分析:求导过程不再赘述。要注意的是,如果全部都是零多项式,最后要输出"0 0"#include <iostream>#include <cstdio>using namespace std;typedef struct Part{ int _ratio; int _index; void deriva...

2020-02-02 11:37:29 217

原创 1009 说反话 (20分)

Github代码(不全,更新中)分析:逆置部分同1008,另外读入时注意结束标志#include <iostream>#include <cstdio>using namespace std;void inverse(string arr[], int head, int tail){ for(int i=head, j=tail-1; i<j...

2020-02-02 11:31:41 207

原创 1008 数组元素循环右移问题 (20分)

Github代码(不全,更新中)分析:将数组进行三次逆置操作,即可得到原地右移数组PS:基础的数据结构题,练习时建议不要取巧直接输出。#include <iostream>#include <algorithm>using namespace std;int inverse(int arr[], int head, int tail){//数组逆置 ...

2020-02-02 11:28:16 489

原创 1007 素数对猜想 (20分)

Github代码(不全,更新中)分析:先将1到N之间的素数找出来,然后便利查找素数对PS:如何判定素数?对于正整数n,若比n的小的素数均不能被n整除,则n是素数。{ int n; cin>>n; int prime[n+10]; int ind=0; //找出1到N之间的素数 prime[ind++] = 2; fo...

2020-02-02 11:23:41 182 1

原创 1006 换个格式输出整数 (15分)

Github代码(不全,更新中)分析:水题#include <iostream>#include <algorithm>using namespace std;int main(){ int num, ind=0; cin>>num; int a = num/100; while(a--){ ...

2020-02-02 10:14:14 191

原创 1005 继续(3n+1)猜想 (25分)

Github代码(不全,更新中)分析:定义标记数组,初始化为false,给定数据标记为true。验证过程中设计数据全部标记为false,最后标记为true的数据为最后答案。#include <iostream>#include <algorithm>using namespace std;bool flag[1024];int num[512];i...

2020-02-02 10:12:38 379

原创 1004 成绩排名 (20分)

Github代码(不全,更新中)分析:一边读入数据,一边比较即可,不难#include <iostream>#include <string>using namespace std;typedef struct Student{ string name; string id; int grade; Student(){};//...

2020-02-02 09:56:40 1027

原创 1003 我要通过! (20分)

Github代码(不全,更新中)分析:1.首先保证P前,T后,P和T之间全都是A2.根据题目的第二条和第三条:假如x="AA",则AAPATAA正确-->AAPAATAAAA正确-->AAPAAATAAAAAA正确-->... 2个|1个|2个 2个|2个|2*2个 2个| 3个 | 2*3个 ...

2020-02-02 09:52:41 207

原创 1011 A+B 和 C (15分)

Github代码(不全,更新中)分析:水题,定义long long类型读入数据处理即可#include <iostream>using namespace std;int main(){ int n; long long a, b, c; cin>>n; for(int i=1; i<=n; i++){ ...

2020-02-01 12:03:09 219

原创 1002 写出这个数 (20分)

GitHub代码(不全,更新中)分析:小心,不要将拼音打错#include <iostream>#include <string>using namespace std;string pinyin[] ={"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"};int main(...

2020-02-01 10:27:17 99

原创 1001 害死人不偿命的(3n+1)猜想 (15分)

GitHub代码(不全,更新中)分析:水题,不解释Source Code:#include <iostream>using namespace std;int main(){ int n; int time = 0; cin>>n; while(n != 1) { if(n % 2 == 0)...

2020-02-01 10:22:47 208

原创 PAT甲级 1047 Student List for Course(25 分)

Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Input S...

2018-09-01 10:47:42 165

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

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 ...

2018-09-01 10:31:05 179

原创 PAT甲级1014 Waiting in Line (30)(30 分)

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...

2018-08-19 10:19:16 182

原创 PAT甲级1141 PAT Ranking of Institutions(25 分)

After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.Input Specification:Each input file conta...

2018-08-15 16:58:55 178

原创 PAT甲级1145 Hashing - Average Search Time(25 分)

The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...

2018-08-13 19:13:31 220

原创 PAT甲级1142 Maximal Clique(25 分)

A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adj...

2018-08-13 18:14:51 177

原创 PAT甲级1020 Tree Traversals (25)(25 分)

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 cor...

2018-08-13 13:57:36 243

原创 PAT甲级1143 Lowest Common Ancestor(30 分)

The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively defined as a binary tree which has ...

2018-08-12 21:48:34 268

原创 PAT甲级1147 Heaps(30 分)

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...

2018-08-10 17:19:45 172

原创 PAT甲级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...

2018-08-06 17:54:48 238

原创 使用cmd命令出现“XXX.java:3: 错误: 编码GBK的不可映射字符”解决方案

问题描述:解决方案:在javac后加上 -encoding UTF-8。

2018-07-23 14:30:34 729

原创 ... for the right syntax to use near '?,?,?)' at line 1解决方案com.mysql.jdbc.exceptions.jdbc4.MySQLSynt

错误描述:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '...

2018-07-12 20:51:03 9405 6

原创 The servlets named [xx] and [a.b.xx] are both mapped to the url-pattern [/xx] which is not permitted

原因:报错的LoginServlet中 @WebServlet("/LoginServlet")没有注释掉。解决方案:将该句注释掉即可。

2018-07-12 15:16:19 433

原创 PAT甲级1128 N Queens Puzzle(20 分)

题目链接#include &lt;iostream&gt;#include &lt;algorithm&gt;#include &lt;bits/stdc++.h&gt;using namespace std;int c[3][2048];//数组开到1024段错误......int main(){ int m; scanf("%d",&amp;m); ...

2018-07-10 14:36:06 233

原创 PAT甲级1132 Cut Integer(20 分)

题目链接注意:除数为0的情况。#include &lt;iostream&gt;#include &lt;algorithm&gt;#include &lt;bits/stdc++.h&gt;using namespace std;long long a,b,c,d;int main(){ int n; scanf("%d", &amp;n); for(int...

2018-07-09 19:40:11 209

原创 PAT甲级1136 A Delayed Palindrome(20 分)

题目链接注意:1、PAT提交不能用gets()函数。2、如果数字本身就是一个Palindrome number直接输出。#include &lt;iostream&gt;#include &lt;algorithm&gt;#include &lt;bits/stdc++.h&gt;using namespace std;bool isPalNum(char C[]){//判断是否是一...

2018-07-09 19:09:43 285

原创 PAT甲级 1144 The Missing Number(20 分)

题目链接#include &lt;iostream&gt;#include &lt;bits/stdc++.h&gt;#include &lt;algorithm&gt;using namespace std;int main(){ int n; while(~scanf("%d",&amp;n)) { int arr[100000+1]; ...

2018-07-09 15:40:59 198

原创 PAT 甲级 1140 Look-and-say Sequence(20 分)

题目链接#include &lt;iostream&gt;#include &lt;algorithm&gt;#include &lt;bits/stdc++.h&gt;using namespace std;int main(){ int D; int n; while(~scanf("%d %d", &amp;D, &amp;n)) { ...

2018-07-09 15:39:08 327

原创 "Input Button Submit is not setup"解决方案

点击Hierarchy面板中的EventSystem,在Inspector面板中,勾掉Standalone Input Module。

2018-01-28 15:23:48 6172

构建乘积数组.gif

LeetCode 剑指Offer 66题 构建乘积数组 动态图解

2020-05-10

空空如也

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

TA关注的人

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