-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b783e3
commit 380a453
Showing
6 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cf1672H.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 题解 CF1672H | ||
|
||
感觉这道题很有趣,记录一下。 | ||
|
||
看官方答案没太看懂,根据灵神的解答想明白了怎么证明。 | ||
|
||
首先可以证明每次移除的都是一个完整的 alternative substring。移除不完整的没有任何好处。 | ||
|
||
首先我们考虑所有的 00,11 的个数(允许重叠)。比如 000 里有两个 00。 | ||
|
||
如果场上有 k 个 00,0 个 11,那么很显然需要 k+1 次操作。 | ||
如果场上有 k 个 00,t 个 11,那么我们考虑: | ||
|
||
1. 如果移除的是一个偶数长度的 alt string,那么移出后 00 和 11 各减少 1 个。 | ||
2. 如果移除的是一个奇数长度的 alt string,那么移出后 00 或 11 减少 1 个(其实是减少 2 个,但是前后又拼出 1 个) | ||
3. 如果 00 和 11 的个数都不为 0,那么一定存在一个偶数长度的 alt string。这是因为考虑任意两个 00 11,它们中间必须有至少一个偶数长度的 alt string,否则不可能从 0 变成 1 (奇数长度的 alt string 首尾是一样的) | ||
|
||
基于以上三点我们不难发现,答案应该是 max(`#00`, `#11`) + 1。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ CRTP.md | |
Further Read.md | ||
index.md | ||
UB | ||
Concurrency.md | ||
Concurrency.md | ||
memory_order.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 什么是证书?什么是签名? | ||
|
||
感恩:https://www.youdzone.com/signature.html | ||
|
||
我们知道非对称加密有一对公钥私钥。公钥加密可以用私钥解密;私钥加密可以用公钥解密。 | ||
|
||
数字签名一种用来验证文件完整性真实性的过程。它的流程如下: | ||
|
||
1. 签名的人生成一对密钥,公钥公开,私钥自己拿着。 | ||
2. 当他想签名一个文件的时候,用自己的私钥加密文件的哈希(为了让文件小一点,RSA这种算法跑的很慢)。 | ||
3. 当外人检查这个文件和签名的时候,先用公钥解密签名。然后对比解密后的东西和文件的哈希是否相同 | ||
|
||
从上面这个流程我们可以发现签名可以检查: | ||
|
||
1. 签名确实是这个公钥的私钥持有者签署的。这是由加密算法的安全性保证的。 | ||
2. 文件确实是完整的。这是由哈希一样保证的。 | ||
|
||
但是如果不是线下真人对线,我在网上声称我是马云,我生成了一对密钥,现在把公钥公布。以后难道别人就要相信我真的是马云吗?肯定不是的,因为现在的问题不在于能否验证这个东西是由私钥签署的;现在的问题是我怎么知道这个钥真的是马云的? | ||
|
||
所以我们需要引入一个第三方机构。这是没办法的事情。所以我们只能选择相信一些第三方机构,然后由它们去调查取证要申请证书的网站是不是真实的。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters