自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 JDK源码学习记录---HashMap篇之如何理解tableSizeFor(int cap)

static final int tableSizeFor(int cap) { int n = cap - 1; n |= n >>> 1; n |= n >>> 2; n |= n >>> 4; n |= n >>> 8; n |= n >>> 16; return (n < 0) ? 1 : (.

2021-11-03 18:41:22 270

原创 JDK源码学习记录---HashMap篇之为什么是(n-1)&hash

之前一直在纠结为什么(n-1)&hash=hash%n,后来发现重点不应该是为什么(n-1)&hash=hash%n,而是为什么是(n-1)&hash。这里有个大前提就n必须是2的次幂,当n是2的次幂的时候n-1肯定在所以位上全是1,例如n=8,n-1的二进制位为0111,与n-1进行与操作就相当于对全是1的后三位随机赋0,这样可以得到0000-0111之间的所有值,所以不管(n-1)&hash和hash%n是否相等,前者都是可以做到均匀散列的,当然hash%...

2021-11-03 18:14:01 498 1

原创 JDK源码学习记录---HashMap篇之hashCode为什么要右移16位

static final int hash(Object key) { int h; return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16); }举个例子,假设HashMap容量为16(二进制为10000,n-1=1111),hashCode足够大A:00101010010001001011010100101011B:00101010010001101011010100.

2021-11-03 18:00:57 904

原创 关于mac重启/home目录丢失解决方案

首先vim /etc/auto_master查看home所在行是否被注释,如果没被注释,百度如何关sip,自己创建。如果被注释了,sudovim /etc/auto_master把注释去掉,然后去根目录下执行sudo automount -vc 然后home目录就回来了,如果想在home目录写入东西,再把/etc/auto_master的注释加上,再去根目录执行sudo automount就好了。...

2020-08-05 23:39:39 3435 4

原创 关于mac下iterm2无权访问桌面的解决方案(ls .: Operation not permitted)

今天在使用iterm2访问/Desktop的时候,弹出窗口询问 是否允许iterm2访问桌面,手抖点了否,然后就在/Desktop目录下无法使用ls相关命令了。 显示ls .: Operation not permitted 刚才百度了一下,基本上都在教你,如何关闭sip,想起来前几天/home目录丢失,被"恢复模式"支配的恐惧,我是不想再去碰恢复模式的。 我想既然刚刚有弹窗提醒,那就是应该系统某个地方给我禁止了iterm2在桌面下的操作,然后,我打开 系统偏...

2020-07-21 16:35:32 15586 9

原创 解决idea中无法读取src目录下配置文件问题

如果是maven项目直接在pom.xml文件中build标签下添加<resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> ...

2019-06-24 14:56:59 1543

原创 html学习日记

标题:&lt;head&gt; &lt;title&gt;标题&lt;/title&gt;&lt;/head&gt;设置背景:backgroundstyle="background: url(图片路径);"&lt;hr&gt;分割线href添加连接:&lt;a href="连接地址"&gt;  &lt;/a&gt;添加图片:img,如:&lt;img

2018-03-12 22:30:21 548

转载 linux下c/c++printf输出设置

31m代表字体为红色,0m代表关闭所有属性。常用的ANSI控制码如下(有些不支持):\033[0m 关闭所有属性 \033[1m 高亮\033[2m 亮度减半\033[3m 斜体\033[4m 下划线 \033[5m 闪烁 \033[6m 快闪\033[7m 反显 \033[8m 消隐 \033[9m 中间一道横线10-19 关于

2018-01-11 19:03:21 1077

原创 2018.1.8学习日志gdb

b +行号设置断点b +源文件名:行号b +函数名info break查看断点信息n下一步p 变量名查看变量值c 跳到下一个断点q 终止调试returned 推出函数step 进入函数clear 删除当前断点delete 删除所有断点shell 终端命令段错误:

2018-01-08 20:11:56 506

原创 1.8学习日志makefile

Makefile里的cd命令作用范围只有当前行,没有cd命令的都默认当前行

2018-01-08 19:53:09 292

原创 2018.1.7学习日志gcc

主函数参数:argc为统计argv[]传入个数%[^;]读取不是分号前不是分号的字符-Wall不规范警告time 显示运行时间-O 优化代码-g调试Gdb进入调试静态库文件前三个字母默认lib动态库优先动态库复制到lib文件夹(64位为lib64)才能运行

2018-01-07 20:31:55 314

原创 2018.1.6学习日志Centos命令和vim简单命令

Centos6.0命令:         pwd 获取当前位置         cd ./a进入到当前目录的a目录下         cd ..返回上层目录         cp file1 file2 将file1 覆盖file2(若file2不存在先创建file2再将file1的信息复制到file2中)         ls(显示当前目录信息)         ls .

2018-01-07 09:35:03 325

原创 POJ - 1873 The Fortified Forest

The Fortified ForestTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 6960 Accepted: 1939DescriptionOnce upon a time, in a faraway land, there lived a kin

2017-12-21 21:44:11 369

原创 Graham扫描法(凸包)

分治法jarvis步进法先找到纵坐标最小的点,如果有多个找横坐标最小,设该点为p0,以p0为原点,对所有点进行极角排序,排序规则:链接pip0与横坐标正方向的夹角小的编号小,如果夹角相同,距离p0近的编号小,排完序之后,p0p1pn这三个点一点是凸包上的点(上图的p0p1p8),从编号为2的点依次遍历所有的点,每次取栈顶的两个点连城一条直线(方向由栈顶的第二

2017-12-21 09:01:16 1016

原创 jarvis步进法(凸包)

思路:1.先找到纵坐标最小点p0入栈,遍历剩下的点,找到与水平方向夹角最小的点p1入栈2.遍历所有点找到与栈顶两个点连线夹角最小的点pn入栈,重复该过程,知道找不出下一个pn3.栈里的所有点就是凸包上的点关于怎么找最小角这一步我感觉完全可以替换成每次先把,未入栈的一个点入栈,然后遍历剩下所有点,如果某点在栈顶两点连线的右方,用该点顶替栈顶点,每次遍历完所有的点,标记一下栈顶的点

2017-12-16 21:32:15 3437 1

原创 分治法解决凸包问题

分治法就是吧一个大问题分成几个结构相同的子问题,再把子问题分解成更小的子问题.......     分治法解决凸包问题的大体思路就是,取横坐标最小的点p0和横坐标最大pn的点(这两个点一点在凸包上,这个仔细想想能想明白)然把这两个点连成一条直线,直线上面的半个凸包叫上凸包,直线下面的半个凸包叫下凸包,分别在上凸包和下凸包找出距离直线最大的点pmax,链接p1pmax和pnpmax如下图,又可以

2017-12-15 18:07:46 9444 2

原创 萌新的看毛片(kmp)学习日记(下标从0开始)

bf匹配算法的思想是每次主串和模式串都从0开始匹配,当出现失匹的时候模式串将回退到起点,主串将回退到本次匹配起点的下一位置然后重新进行匹配,这样的匹配方式虽然好理解但是时间复杂度比较高,而kmp每次出现失匹的情况只有模式串回退,主串不回退,如果当前失匹点的位置为s[i],并且前k个元素和从头往后数k个元素匹配(即:"s[0]s[1]s[2]…s[k-1] = "s[i-k].....s[i-1]"...

2017-10-18 19:06:33 2065 1

原创 CodeForces - 404C Restore Graph

Valera had an undirected connected graph without self-loops and multiple edges consisting ofn vertices. The graph had an interesting property: there were at mostk edges adjacent to each of its ver

2017-10-17 11:21:43 348

原创 HDU - 5983 Pocket Cube

The Pocket Cube, also known as the Mini Cube or the Ice Cube, is the 2 × 2 × 2 equivalence of a Rubik’s Cube.The cube consists of 8 pieces, all corners. Each piece is labeled by a three dimensio

2017-10-17 11:14:51 432

原创 Jury Jeopardy

ury JeopardyWhat would a programming contest be without a problem featuring an ASCII-maze? Do notdespair: one of the judges has designed such a problem.source: xkcd.com/246The problem

2017-10-17 11:07:06 450

原创 Illegal or Not?

The Schengen Agreement was signed by a number of countries to uniform many visa-related questions and to allow tourists from outside of the Schengen area to enter and freely travel within Schengen mem

2017-10-17 10:55:36 299

原创 HDU - 5583 Kingdom of Black and White

In the Kingdom of Black and White (KBW), there are two kinds of frogs: black frog and white frog.Now Nfrogs are standing in a line, some of them are black, the others are white. The total

2017-10-16 11:25:04 359

原创 hdu 5578 Friendship of Frog

N frogs from different countries are standing in a line. Each country is represented by a lowercase letter. The distance between adjacent frogs (e.g. the1st and the 2nd frog, the N−1th

2017-10-16 11:20:23 363

原创 B Quality of Check Digits

原题戳这里由4位数加前导0求出第5位数,这5位数根据表格给的推回去是0,求给出的表格有多少个数抄错检查不出来暴力跑表格a了...2333333#include #include #include #include #include using namespace std;int s[20][20];int judge(int a1, int

2017-10-16 11:09:19 416

原创 Gym Commandos

StatementsA commando is a soldier of an elite light infantry often specializing in amphibious landings, abseiling or parachuting. This time our Commando unit wants to free as many hostages as it c

2017-10-16 11:04:18 250

原创 CF 440 div2 B.Maximum of Maximums of Minimums

Maximum of Maximums of Minimumstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a1, a2, ..., an c

2017-10-16 10:53:00 374

原创 2017ACM-ICPC南宁网络赛Frequent Subsets Problem(康托展开+bfs)

In this problem, we will define a graph called star graph, and the question is to find the minimum distance between two given nodes in the star graph.Given an integer nnn, an n−dimensionaln-dimens

2017-09-26 09:50:28 420

原创 UVALive - 6320 Encrypted Password

Encrypting passwords is one of the most important problems nowadays, and you trust only the encryp-tion algorithms which you invented, and you have just made a new encryption algorithm.Given a

2017-09-09 21:11:06 336

原创 HDU - 4027 Can you answer these queries?(线段树)

Can you answer these queries?Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 18765    Accepted Submission(s): 4425Problem Description

2017-08-22 19:55:33 251

原创 Gym - 101102C Bored Judge

Judge Bahosain was bored at ACM AmrahCPC 2016 as the winner of the contest had the first rank from the second hour until the end of the contest.Bahosain is studying the results of the past contests

2017-08-19 09:52:03 363

原创 POJ - 1797 Heavy Transportation

Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his cu

2017-08-03 19:44:14 273

原创 POJ - 2253 Frogger

Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sun

2017-08-03 09:01:07 211

原创 POJ - 3414 Pots

Time Limit: 1000MS  Memory Limit: 65536KTotal Submissions: 18011 Accepted: 7622 Special JudgeDescriptionYou are given two pots, having the volume of A and B liter

2017-07-31 20:43:06 234

原创 UVA - 11624 Fire!

https://odzkskevi.qnssl.com/f08168bf425521a08eac790e3a9ae7e3?v=1501046780这个题的意思就是J在迷宫内,一部分迷宫着火了(F),F和J每分钟都走一格,且都不能穿墙,当J走到迷宫的边缘时可以穿出迷宫(穿出迷宫需要一分钟的时间),让求出走出迷宫最小时间,如果走不出输出IMPOSSIBLE。将F和J的位置同时入队bfs

2017-07-31 10:40:26 289

原创 HDU - 2612 Find a way

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 32533    Accepted Submission(s): 18896Problem DescriptionThe GeoSurvComp geologic surv

2017-07-31 08:53:04 245

原创 HDU - 2181 哈密顿绕行世界问题

一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。Input 前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m=1.m=0退出. Output 输出从第m个城市出发经过每个城市1次又回到m的所有路线,如有多条路线,按字典序输出,每行1条路线.每行首先输出是第几条路线.然

2017-07-29 20:53:11 235

原创 HDU - 1241 Oil Deposits

The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides th

2017-07-29 20:48:13 200

原创 LightOJ - 1012 Guilty Prince

Once there was a king named Akbar. He had a son named Shahjahan. For an unforgivable reason the king wanted him to leave the kingdom. Since he loved his son he decided his son would be banished in a n

2017-07-29 20:42:56 510

原创 HDU - 1242 Rescue

Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.Angel's friends want t

2017-07-29 20:39:21 304

原创 POJ - 1088 滑雪

Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813

2017-07-29 20:28:28 213

空空如也

空空如也

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

TA关注的人

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