Welcome to Yang's Website
This is Yang’s Website.
This is Yang’s Website.
http://www.righto.com/2014/09/mining-bitcoin-with-pencil-and-paper.html
This article introduces the process how mining works in Bitcoin, which requires miners to find a hash smaller than a specific value. The author also shows the process calculating SHA-256, one of the hash functions, using pen and paper.
https://www.coindesk.com/viabtc-mystery-miner-bitcoin-scaling-future
This article introduces a bitcoin mining pool in China called ViaBTC became to support Bitcoin Unlimited instead of Bitcoin Core. There are two ways that are possible to scale the bitcoin block size: Segregated Witness and Bitcoin Unlimited. Segregated Witness is a planned technical fix that would make bitcoin’s block size about 1.8 times larger than original size, while Bitcoin Unlimited allows miners and individual node operator to choose a block size that they prefer instead of limited block size. Either side has its supporters and have continued arguing.
https://www.coindesk.com/antbleed-bitcoins-newest-new-controversy-explained
This article introduces a mining chip vulnerability, which some are calling a “backdoor”, that could potentially be used to remotely shut off bitcoin mining machines. The public fears that someone could exploit the vulnerability to switch off bitcoin mining equipment in bulk and involving mining chip manufacturer Bitmain has been controversial.
https://github.com/ethereum/wiki/wiki/%5B中文%5D-以太坊白皮书
This article first introduces the history of bitcoin and its general principle. Then it states the advantages of implementing some specific functions on ethereum beyond those on bitcoin such as script. It also enumerates other applications of ethereum in practice.
This article shows chatlogs between Chinese miners and a Litecoin developer discussing activating Segwit on Litecoin. Jihan, one of the Chinese miners, supported to activate the Segwit with a hard fork, while Xinxi, a LTC developer, argued that it should be activated with soft ford instead.
John 有一个计数器,记录从某次越狱开始每天距离上次奶牛越狱的天数(越狱当天为0)。当他打算统计时,计数器上某些天数被涂掉了(用 -1 表示)。给出总天数 N 和每天记录的天数,返回 N 天中奶牛越狱次数可能的最小值和最大值,若记录的天数有矛盾的地方,返回 -1
根据题目,第一天的数字一定为 0。将记录计数的数组复制一份,原数组用于参考数据,并在新数组上进行更改。从后往前遍历原数组,每当发现一个不为 -1 的元素 m,在新数组中将该元素前 m 个元素更改为相应的降序数字,过程中若发现矛盾,返回 -1。遍历完成后,新数组中 0 的数量即为越狱次数的最小值,0 与 -1 的总数量为最大值
由于只需要遍历一次数组,时间复杂度为 O(n),且 N 最大为 100,不会超时
Famer John 和 Bessie 猜拳。在 $n$ 次猜拳中 ($1 ≤ n ≤ 100000$),Bessie 只会变一次手势,给出 Farmer John 每次出的手势,求 Bessie 能赢的最大次数
将 FJ 每次出的手势装进一个 prefix 数组中,数组的每个元素是当前 FJ 出过三个手势分别的次数。遍历装 FJ 手势的数组,计算每次 Bessie 赢的次数,并求出最大值
创建一个 prefix 数组的复杂度为 $O(n)$,遍历数组的复杂度为 $O(n)$,利用 prefix 计算赢的次数的复杂度为 $O(1)$,总复杂度为 $O(n)$,$n$ 最大为 100000,不会超时
1 | def win(a, b, i): |
一共有 $n$ 头奶牛,每头奶牛站在不同的位置 $(x, y)$,并拥有一个广播半径为 $p$ 的对讲机(每只奶牛的 $p$ 不一定相同)。求从某只奶牛开始能联系到最多的奶牛数是多少(单向)
将奶牛坐标装进一个数组中,将每只奶牛的 $p$ 装进另一个 $index$ 都一一对应的数组。遍历装坐标的数组,利用递归计算当前奶牛能联系到的所有奶牛数,并得出最大值
遍历长度为 $n$ 数组的复杂度为 $O(n)$,其中每个元素递归最坏的复杂度也为 $O(n)$,总复杂度为 $O(n^2)$。$n$ 最大为 200,不会超时
1 | def distance(p1, p2): |
给出 N 个城市(1 ≤ N ≤ 200000),每个城市有自己的名字和长度为两个字母的代号(可能会重复)。若两个城市是一对 special pair ,则这两个城市的名称的前两个字母都是对方的代号。找出这 N 个城市中有多少对 special pair
将城市的前两个字母和代号分别装进一个长度为 2 的元组的两个房间,并将每个这样的元组装进 hashmap 中,其中每个元组作为 key,出现的次数作为 value。遍历 hashmap,将当前的元组的前后两格互换,若 hashmap 中有与新元组相同的 key,则 count 加上当前的 valve 与新 value 的积
遍历 hashmap 的复杂度为 O(N),在 hashmap 中查找 key 的复杂度为 O(1),总复杂度为 O(N)。N 最大为 200000,不会超时