thumbnail
二进制与位运算
二进制 二进制([latex]Binary System[/latex])是一种以 [latex]2[/latex] 为基数的数制,只使用两个数字符号:[latex]0[/latex] 和 [latex]1[/latex], 每个数字称为一个比特([latex]Bit[/latex],[latex]Binary digit[/latex]…
thumbnail
动态规划题目详解
1.Vacations 链接:https://codeforces.com/problemset/problem/698/A 思路:     定义 [latex]dp[i][j][/latex] 为第 [latex]i[/latex] 天为 [latex]j[/latex] 时前 [latex]i[/late…
thumbnail
全区间函数值求和问题
摘要     “全区间函数值求和”是一个常见的算法模式:给定数组 [latex]a[1..n][/latex],我们要对所有子数组 [latex][L, R] (1 ≤ L ≤ R ≤ n)[/latex] 计算某个函数 [latex]f(L, R)[/latex] 的值,并把它们相加,求: [latex]\…
thumbnail
前缀和详解及其拓展
    前缀和(Prefix Sum) 是一个经典而高效的技巧,常用于快速查询数组区间和、处理计数类问题、解决某些离散数学性质问题。 一维前缀和     一维前缀和是指一个数组中从第一个元素开始,到当前位置的所有元素之和所构成的新数组。   &nbs…
thumbnail
算法模板
0 初始化 0.1 初始化1 /* __ __ ___ __ __ _ _ _ | \/ | |_ _| \ \ / / / \ | \ | | | |\/| | | | \ V / / _ \ | \| | | | | | | | | | / ___ \ | |\ | |_| |_| |___| |_| /_/ \_\ |_| \_| */ #i…
thumbnail
AtCoder Beginner Contest 428
链接:https://atcoder.jp/contests/abc428 A - Grandma's Footsteps 算法:     模拟。 思路:     无。 关键代码: void miyan() { int s, a, b, x; cin >> s >> a…
thumbnail
Codeforces Round 1058 (Div. 2)
链接:https://codeforces.com/contest/2160 A. MEX Partition 算法:     贪心。 思路:     无。 关键代码: void miyan() { int n; cin >> n; set<int> s; for (int i = 0; i < …
thumbnail
Codeforces Round 1057 (Div. 2)
链接:https://codeforces.com/contest/2153 A. Circle of Apple Trees 算法:     贪心。 思路:     不同元素的个数。 关键代码: void miyan() { int n; cin >> n; vector<int> a(n); for (auto &x : a) c…
thumbnail
AtCoder Beginner Contest 427
链接:https://atcoder.jp/contests/abc427 A - ABC -> AC 算法:     模拟。 思路:     无。 关键代码: void miyan() { string s; cin >> s; for (int i = 0; i &…
thumbnail
AtCoder Beginner Contest 426
链接:https://atcoder.jp/contests/abc426 A - OS Versions 算法:     模拟。 思路:     无。 关键代码: void miyan() { string s, t; cin >> s >> t; map<st…
thumbnail
AtCoder Beginner Contest 401
链接:https://atcoder.jp/contests/abc401 A - Status Code 算法:     模拟。 思路:     无。 关键代码: void miyan() { int n; cin >> n; if (n <= 299 &…
thumbnail
AtCoder Beginner Contest 402
链接:https://atcoder.jp/contests/abc402 A - CBC 算法:     模拟。 思路:     无。 关键代码: void miyan() { string s; cin >> s; string ans; for (auto c :…
thumbnail
AtCoder Beginner Contest 425
链接:https://atcoder.jp/contests/abc425 A - Sigma Cubes 算法:     模拟。 思路:     无。 关键代码: void miyan() { int n; cin >> n; ll ans = 0; for (int…