博客迁移记录

从hexo到hugo 从高中开始就采用hexo+GitHub Pages的方式搭建博客,hexo确实很强大,但是由于需要借助node的原因,用起来总是没那么舒服,尤其是在换了电脑之后,配置环境比较麻烦,npm install也比较臃肿,于是决定采用hugo。 hugo是一个使用go语言开发的博客框架,由于是go编写的,所以渲染速度总的来说比hexo快不少,而且安装起来也很简单,也有不少美观的主题,方便部署到各个平台。 环境配置 系统环境:macOS arm64 (M1 Silicon) Go Version: go1.16beta1 darwin/arm64 homebrew版本:3.0.5 我是用的为arm平台的golang,没有测试过用intel平台的go版本进行配置 安装hugo 1 brew install hugo 创建一个新网站 1 hugo new site blog 添加一个主题 1 2 git init // 初始化git git submodule add https://github.com/CaiJimmy/hugo-theme-stack/ themes/hugo-theme-stack //主题下载 添加篇文章 我的主题文章保存在了content文件夹中的post目录 1 hugo new /post/first.md 本地进行渲染预览 1 hugo server -D 之后可以通过打开localhost:1313来进行预览 部署到GitHub仓库 1 2 3 4 5 6 7 hugo -D cd public git init git add . git commit -m "first commit" git remote add origin https://github.

Luogu3964-松鼠聚会

Luogu3964

Description

草原上住着一群小松鼠,每个小松鼠都有一个家。时间长了,大家觉得应该聚一聚。但是草原非常大,松鼠们都很头疼应该在谁家聚会才最合理。 每个小松鼠的家可以用一个点$(x,y)$表示,两个点的距离定义为点 $(x,y)$ 和它周围的8个点 $(x-1,y),(x+1,y),(x,y-1),(x,y+1)$ $(x−1,y+1),(x-1,y-1),(x+1,y+1),(x+1,y-1)$距离为1。输出一个整数,表示松鼠为了聚会走的路程和最小是多少。

51nod3143-切比雪夫距离与曼哈顿距离

51nod3143

Description

n位战士即将奔赴战场,他们每个人都有一个攻击值ai和一个防御值bi,现在你想设计一种装备给这n位战士,如果这件装备的攻击值为A,防御值为B,那么对于第i位战士这件装备的不匹配度为$max(|A−a_i|,|B−b_i|)$ A,B都是正整数,要让所有战士的不匹配度之和最小,求出最小的不匹配度之和$2\le N \le 100000$

莫队-小B的询问洛谷P2709

Description P2709 小B 有一个长为n的整数序列$a$,值域为$[1,k]$。 他一共有m个询问,每个询问给定一个区间$[l,r]$ 求:$\sum_{i=1}^k c_i^2$ 其中 $c_i$ 表示数字 $i$ 在$[l,r]$ 中的出现次数。 小B请你帮助他回答询问。 Solution 莫队算法板子题 mark Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <queue> #include <cmath> #include <map> #include <set> #define mem(a,b) memset(a,b,sizeof(a)) #define debug cout<<0<<endl #define ll long long const int MAXN = 5e4 + 10; const int MOD = 1e9 + 7; using namespace std; struct Q{ int l, r, k; } q[MAXN]; int N, M, K; int pos[MAXN], a[MAXN], cnt[MAXN]; ll ans[MAXN]; ll res; inline void Add(int n) { cnt[a[n]]++; res += 2ll*cnt[a[n]] - 1; } inline void Sub(int n) { cnt[a[n]]--; res -= 2ll*cnt[a[n]] + 1; } int main() { ios::sync_with_stdio(false); cin.

GCD-兔八哥与猎人

Description 兔八哥躲藏在树林旁边的果园里。果园有M × N棵树,组成一个M行N列的矩阵,水平或垂直相邻的两棵树的距离为1。兔八哥在一棵果树下。 猎人背着猎枪走进了果园,他爬上一棵果树,准备杀死兔八哥。 如果猎人与兔八哥之间没有其它的果树,猎人就可以看到兔八哥。 现己知猎人和兔八哥的位置,编写程序判断兔子所在的位置是否安全. 输入: 第一行为n,表示有n(n ≤ 100,000)组数据,每组数据的第一行为两个正整数ax和ay,表示猎人的位置,第二行为两个正整数bx和by,表示兔八哥的位置(1 ≤ ax, ay, bx, by ≤ 100,000,000)。 输出: 共有n行,每行为“yes”或“no”表示兔八哥的位置是否安全。 Solution 容易想到,兔八哥和猎人只要连线上无整数点即可,可以转化成$|a_x - b_x| 和 |a_y - b_y|$互质,即$gcd(|a_x - b_x|,|a_y - b_y|)=1$ Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) typedef long long ll; typedef unsigned long long ull; using namespace std; inline int gcd(int a, int b) { return b == 0 ?

统计硬币-递推/DP

Description HDU 2566 假设一堆由1分、2分、5分组成的n个硬币总面值为m分,求一共有多少种可能的组合方式(某种面值的硬币可以数量可以为0)。 Solution 坑题,没给数据范围,只能瞎猜,一发搜索挂掉发现无法去重,但是考虑到该问题满足从1开始分配并无后效性,可以直接递推(类似背包),三种物品可选任意次 Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) typedef long long ll; typedef unsigned long long ull; using namespace std; int main() { //freopen("test.txt", "r", stdin); ios::sync_with_stdio(false); int N, M; int ans; int dp[2000][2000]; int n[] = {1,2,5}; cin.
0%