zxlg's notes


  • 首页

  • 归档

  • 标签

  • 分类

  • 关于

  • 搜索

求幂的高效算法

发表于 2017-08-30 | 更新于: 2019-08-12 | 分类于 算法 | 阅读次数:

求解a^n次方,正常求解需要O(n)时间,若n很大,则需要更快速的算法

快速幂

基础:任何一个数都可以用二进制表示
若需求3^11,可将指数进行一个logN的变换,11 = 2^3 + 2^1 + 2^0,只需算3^8,3^2,3^1,再将其相乘。

阅读全文 »

找出100万以内的质数

发表于 2017-08-30 | 更新于: 2019-08-12 | 分类于 算法 | 阅读次数:

暴力测试

最简单的算法,从2枚举到sqrt(n)就可以知道是不是素数了。

费马小定理

对于质数n和任意整数a,有a^n ≡ a(mod n)(同余)。
反之,若满足a^n≡a(mod n),n也有很大概率为质数,称n是一个基于a的伪素数。将两边同时约去一个n,则有a^(n−1)≡1(mod n)。

这个定理是来判断一个数字是不是合数的,而不是素数。如果不符费马小定理,一定是合数, 如果符合费马小定理不一定是素数(但是是素数的可能性比较高)。

如果判定n为合数,那么结果一定正确。如果判定n为质数,那么只有当n是基于2的伪素数时才会出错

阅读全文 »

八大排序算法总结

发表于 2017-08-28 | 更新于: 2019-08-12 | 分类于 算法 | 阅读次数:

ES6常用性质总结

发表于 2017-08-23 | 更新于: 2019-08-12 | 分类于 Javascript | 阅读次数:

class

箭头函数

异步

Windows下node版本管理

发表于 2017-08-23 | 更新于: 2019-08-12 | 分类于 Node | 阅读次数:

原因

因为ES6的兴起,很多新特性在浏览器中实现不了,甚至低版本的node也不能实现,所以需要一个node版本管理工具,nvm不支持windows,但nvm-windows支持,也持续在更新。

阅读全文 »

CSS定宽+自适应布局

发表于 2017-08-22 | 更新于: 2019-08-12 | 分类于 CSS | 阅读次数:

定宽+自适应两列布局

absolute + margin

1
2
3
4
5
<div class="container">
<div class="main">主列</div>
<div class="sidebar">边栏</div>
</div>
<div class="footer"></div>
阅读全文 »

精通CSS笔记与心得

发表于 2017-08-22 | 更新于: 2019-08-12 | 分类于 CSS | 阅读次数:

2017-08-24更新


基础知识

文档类型

DOCTYP切换

浏览器模式

阅读全文 »

Javascript继承总结

发表于 2017-08-22 | 更新于: 2019-08-12 | 分类于 Javascript | 阅读次数:

面向对象的语言一般都支持接口继承和实现继承,而Javascript的函数没有签名,所以只支持实现继承。

Git原理和常用命令总结

发表于 2017-08-21 | 更新于: 2019-02-24 | 分类于 Git | 阅读次数:

git存储原理

内容寻址文件系统

git常用命令

1
2
3
4
5
6
7
git add
git commit
git push
git pull
git reset
git reflog # 查看全部操作纪录,可回退到由于重置而导致的纪录丢失
git cherry-pick

git http免密登录

  1. 新建git-credentials文件
    touch ~/git-credentials, window中为用户文件夹下新建git-credentials文件

  2. 编辑git-credentials文件
    vim gitgit-credentials, 添加https://{用户名}:{密码}@github.com

  3. 使得git-credentials生效
    执行git config --global credential.helper store

  4. 查看~/.gitconfig文件变化
    多了如下代码:

1
2
[credential]
helper = store

Git push error解决方案

发表于 2017-08-20 | 更新于: 2019-08-12 | 分类于 Git | 阅读次数:

操作过程

校园网git push推送时出现

1
2
3
4
5
6
7
8
9
10
11
ssh_dispatch_run_fatal: Connection to 192.30.255.112: Software caused connection abort
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: ssh_dispatch_run_fatal: Connection to 192.30.255.112: Software caused connection abort
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

阅读全文 »
1234…7
zxlg

zxlg

65 日志
23 分类
98 标签
RSS
微博 GitHub
Creative Commons
© 2021 zxlg
由 Hexo 强力驱动
|
主题 — NexT.Mist