Hitomi's Note
瞳の笔记

Codeforces Round 736 (Div. 2 & 1) [CF-1549 & CF-1548]

发布于|# ACM# CodeForces

A - Gregor and Cryptography Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them. Gregor's favorite prime number is $P$. Gregor wants to find two bases of $P$. Formally, Gregor is looking for two integers $a$ and $b$ which satisfy both of the following properties. $P\mod a=P\mod b$, where $x\mod y$

Educational Codeforces Round 112 (Rated for Div. 2) [CF-1555]

发布于|# ACM# CodeForces

A - PizzaForces PizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of $6$ slices, medium ones consist of $8$ slices, and large pizzas consist of $10$ slices each. Baking them takes $15$, $20$ and $25$ minutes, respectively. Petya's birthday is today, and $n$ of his friends will come, so he decided to make an order from his favorite pi

Codeforces Global Round 15 [CF - 1552]

发布于|# ACM# CodeForces

A - Subsequence Permutation A string $s$ of length $n$, consisting of lowercase letters of the English alphabet, is given. You must choose some number $k$ between $0$ and $n$. Then, you select $k$ characters of $s$ and permute them however you want. In this process, the positions of the other $n

Python 模板注入

发布于|# CTF# Web

剖析原理 首先我们需要理解一下 Python 的几种数据类型,笔者这里将常见数据类型放入一个列表中再进行依次打印,例如: Python3: Python2: 我们可以看到,使用 type 来进行检查数据类型时,会返回 <class 'XXX'>,那么我们会注意到 XXX 前的 class,在编程语言中,class 是用来定义类的。是的,没错,在 Python 中,一个字符串则为 str 类的对象,一个整形则为 int 类的对象,一个浮点数据则为 float 的对象。.. 我们可以通过 id 来看一下这些对象的编号是多少,如图: 得出首条结论:在 Python 中,一切皆对象。 那么知道这些有什么用呢?一个对象则存在属性与方法,我们可以通过 dir 来进行查看,如图 ( 这里用普通字符串来进行举例 ) : 我们可以看到字符串 python2 与 python3 都返回了

Pwntools 安装指南

发布于|# CTF# PWN

安装 Ubuntu 系统。 自选虚拟机或 WSL。WSL 安装方式详见前篇。 WSL2 安装教程 安装 pip 及依赖库 apt-get update apt-get install python3 python3-pip python3-dev git libssl-dev libffi-dev build-essential python3 -m pip install --upgrade pip 更换 pip 为国内源 修改 ~/.pip/pip.conf 文件,替换为国内镜像源 mkdir ~/.pip vi ~/.pip/pip.conf [global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com 安装 Pwnto

Stegseek 暴力解 Steghide 隐写数据

发布于|# CTF# Misc

安装 Github Release 下载 deb 安装包,使用命令安装。 sudo apt install ./XXX.deb 常用命令 加密文件爆破 stegseek [加密文件] [字典] 无加密隐写文件爆破 stegseek --seed [隐写文件] 附注:手动编译 git clone https://github.com/RickdeJager/stegseek sudo apt install -y libmhash-dev libmcrypt-dev libjpeg62-dev zlib1g-dev build-essential cmake cmake . make -j8

并查集

发布于|# ACM# 树

作用 寻找两个点是否联通 求最小生成树。 例题 每个人都知道自己的领导,问谁是最终的领导。 计算圈子总个数 思路 常规思路 递归寻找上级,由上级再次寻找。直到无法找到上级为止。 常用于在单树中寻找最高节点。 路径压缩 孙节点和父节点直接挂载在爷节点之下。 常用于计算不连通的树的个数。 代码 #include<iostream> #include<cstdio> using namespace std; int pre[1000]; int unionSearch(int root) { int son, tmp; son = root; while (root != pre[root]) root = pre[root]; while (son != root) {

多重背包

发布于|# ACM# 动态规划

例题 有 N 种物品和一个容量为 V 的背包。第 i 种物品最多有 M[i] 件可用,每件耗费的空间是 C[i] ,价值是 W[i] 。求解将哪些物品装入背包可使这些物品的耗费的空间总和不超过背包容量,且价值总和最大。 思路 根据 01 背包的方式, $$ F[i , v] = max{F[i - 1,v - k \times C_i ] + k \times W_i | 0 \le k \le M_i } $$ 代码 #include <cstdio> #include <iostream> using namespace std; int main() { int n, m; int dp[1005]; int weight[1005], value[1005], num[1005]; cin >> n >&

完全背包

发布于|# ACM# 动态规划

例题 有 N 种物品和一个容量为 V 的背包,每种物品都有无限件可用。放入第 i 种物品的费用是 C[i] ,价值是 W[i] 。求解:将哪些物品装入背包,可使这些物品的耗费的费用总和不超过背包容量,且价值总和最大。 思路 按照 01 背包相同的思路, $$ F[i,v] = max{F[i - 1,v - kC_i ] + kW_i | 0 \le kC_i \le v} $$ 代码 #include<cstdio> #include<iostream> #define maxn 1000 using namespace std; int W[maxn], V[maxn]; int main() { int m, n; int dp[maxn]; dp[0] = 0; cin >> m; cin >&g

01 背包

发布于|# ACM# 动态规划

例题 有 N 件物品和一个容量为 V 的背包。放入第 i 件物品占用的容量是 C[i] ,得到的价值是 W[i] 。求解将哪些物品装入背包可使价值总和最大。 思路 物品仅有两种状态,即放与不放。 如果不放第 i 件物品,那么最大价值为 F[i - 1,v] ;如果放第 i 件物品,那么价值就是 F[i - 1,v - C[i]] 再加上通过放入第 i 件物品获得的价值 W[i] 。 $$ F[i,v] = \max {F[i - 1,v],F[i - 1,v - C_i ] + W_i } $$ 代码 #include<iostream> using namespace std; const int maxn = 1000; int main() { int m[maxn][maxn]; int w[maxn], v[maxn]; int C, N;