Cost of 01 and 10 Pairs

Problem

Recently, a friend has met a question in pre-interview machine test:

Given a string \(s\) containing characters 0, 1, or ?, and integer parameters \(x\) and \(y\), while \(1 \leq len(s) < 10^5, 1 \leq x < 10^5, 1 \leq y < 10^5\).

For any string only containing 0 and 1, we define its cost as $$x \cdot p_{01} + y \cdot p_{10}$$ while:

  • \( p_{01} \): the number of 01 subsequences in \(s\), not substrings, digit 0 and digit 1 needn’t to be neighbors in \(s\).
  • \( p_{10} \): the number of 10 subsequences in \(s\).

You should replace all the characters ? in string \(s\) with characters 0 or 1 to get a string \(s'\), please calculate the minimum cost of all the possible \(s'\).

Fuck the GFW in 2023

目标

经过多年的发展和迭代,v2ray或者xray已经成为了fuck-the-gfw领域的事实标准。 目前xray的vless + reality + vision协议的方案稳定性和速度都非常令人满意,只要机房节点合适,体验非常舒适。

但是经过代理访问网络服务时,有时候会给我们带来额外的困扰,例如Netflix以及ChatGPT都会检查访问者的IP属性,如果是来自于机房数据中心,可能会直接拒绝服务。

使用xkeysnail交换键位

xkeysnail

xkeysnial是一款进行键位映射的软件,通过xkeysnail可以很方便地进行键位自定义。

1
2
sudo apt install python3-pip
sudo pip3 install xkeysnail

配置

由于Ctrl键相比于CapsLock键更加常用,而CapsLock键的位置更容易按到,交换这两个键位会使得按键过程更加舒适和高效。 使用如下脚本即可配置xkeysnail的自动service,将会在进入用户账户时自动执行交换键位的脚本。

使用Hugo写博客

简介

Hugo是用Go语言写成的静态网站生成器,由于是使用Go语言写成,安装部署非常便利,只需要下载binary文件即可,非常方便。 此外Hugo具有很高的效率,能够以很快的速度生成静态网页。此外Hugo开发者社区活跃,更新快速,有大量的漂亮的主题。

安装

首先到Github官方repo的releases下载最新binary,解压文件后将hugo binary文件放到系统的PATH目录下。

使用Caddy托管博客

安装Caddy

Caddy是Go语言实现的HTTP/2 web server,且默认自动开启HTTPS,配置简单,使用方便,非常适合用于博客。

首先从Caddy download下载binary,在下载时可以选择所需要的plugin,例如本站选择了nethook-service两种plugin。