Link. Luogu Description. 有 \(n\) 个人,第 \(i\) 个人说有 \(a_i\) 个人成绩比他高,有 \(b_i\) 个比他低。 问至少几个人说谎了。 Solution. 首先考虑每个人说的话本质含义是什么。 相当于对他来说,第 \(a_i+1\) 个人到第 \(n-b_i\) 人分数相同。 我们分别设 \(l_i=a_i+1,r_i=n-b_i
就先定个小目标每天写他个三题(x),但最近还是有点累,大概就还是写点简单的题(Div2里ABCD差不多,EF这种过段时间如果状态好点补上) https://www.luogu.com.cn/problem/P2260求\(\begin{aligned}\sum_{i=1}^n \sum_{j=1}^m (n\bmod i)(m\bmod j),(i\neq j),n,m\leq 10^9\end{aligned}\)取
题目链接:https://acm.hdu.edu.cn/showproblem.php?pid=1663 记录一下某数字出现的次数,每个数字都单独算一遍即可 #include<cstdio> #include<cstring> #include<vector> using namespace std; typedef long long ll; const int maxn = 30; int l, r; ll dp[maxn][maxn], ans[max
Yet Another Problem About Pi 题意: 平面上有无穷个长,宽为w,d的矩形方格。你有一条长度为Π的曲线可以任意弯折,起点任意,求曲线最多经过的方格数目(不计边界) 思路: 先考虑最坏情况:对应max(w,d)>PI时,我们不能越过任何一个方格,此时我们的最佳方案应该是以四个矩形方格的交点为
二分$T$和$S$第一个不同的位置,即需要对于$s$,判定是否存在$T[1,s]=S[1,s]$且满足条件的$T$ (注:这里的条件不包含$T$的字典序最小) 显然$T[1,s]$已经确定,记其中第$i$种字母出现次数为$a_{i}$ 而
目录题目解法代码 题目 传送门 解法 考虑一次操作 \((0,x,y,k)\) 对前缀和 \(s_i\) 的影响: \[\Delta =\begin{cases} k\cdot(i-x+1), & x\le i\le y \\k\cdot (y-x+1), & i>y\end{cases} \]先给每个下标设定一个 \(c_i\) 表示增加的定值,\(k_i\) 表示增加的 \(i\) 的系数。 那么询
An Easy Problem 1 #include<iostream> 2 using namespace std; 3 4 int cnt(int n){ 5 int sum=0; 6 while(n){ 7 if(n%2)sum++; 8 n/=2; 9 } 10 return sum; 11 } 12 int main(){ 13 int n; 14 while(cin>>
思路: 先考虑暴力的做法,\(O(n^2)\)枚举所有的区间,计算后取最大值。 考虑怎么优化一下,可以发现,如果当前的左端点为\(l\),那么将\(a_l,a_{l+m},a_{l+2m}\)的值全部减去\(k\),那么当求和时选到这些数的时候\(\frac{r-l+1}{m}\)就会加一,也就满足了所求式子的后半段。由于\(m\)很小,我们可
/** * This problem was asked by Pivotal. Write an algorithm that finds the total number of set bits in all integers between 1 and N. * */ class Problem_959 { /* * solution 1: run a loop from 1 to n and sum the count of set bit, Time:O(nlogn)
@目录一、ceres::ProblemProblem::AddResidualBlock()Problem::AddParameterBlock()Problem::SetParameterBlockConstant() 和 SetParameterBlockVariable(). 一、ceres::Problem Problem包含两个主要的成员函数Problem::AddResidalBlock() and Problem::AddParameterBlock() Prob
@目录一、介绍二、简单的例子2.1 定义CostFunction2.2 构建最小二乘问题求解三、3种求导形式3.1 自动求导3.2 数值导数(即人工求导)3.3 分析导数四、多个CostFunction4.1 定义每一个CostFunction4.2 添加ResidualBlock五、曲线拟合5.1 定义CostFunction5.2 添加ResidualBlock六、鲁
文章目录 一、介绍二、简单的例子2.1 定义CostFunction2.2 构建最小二乘问题求解 三、3种求导形式3.1 自动求导3.2 数值导数(即人工求导)3.3 分析导数 四、多个CostFunction4.1 定义每一个CostFunction4.2 添加ResidualBlock 五、曲线拟合5.1 定义CostFunction5.2 添加Residu
目录对抗搜索轮流搜索对抗搜索(博弈搜索)对抗记忆化min_max搜索模板(最大最小化搜索/博弈搜索)井字格游戏(博弈搜索Problem J. Situation)井子格ac代码资料 对抗搜索 轮流搜索 op的值为0或1,通过1-op来使得op可以在0和1之间进行切换 int dfs(int op){ if(op) dfs(1-op);
fatal: unable to access ‘http://gitee.com/yhhyu2015/CommonUtils.git/’: SSL certificate problem: self signed certificate in certificate chain 如果连接git是报错unable to access ‘https://****’: SSL certificate problem: Invalid 因为有些服务器是https是自
原题链接 ( AcWing版 ) 原题链接 ( 洛谷版 ) 题目描述 给定两个正整数 A A A 和 B B B,请你计算
Kattis Problem - Freckles 原题地址 题目类型:最小生成树 题意: 在纸上有 n 个点(坐标形式给出),可以用钢笔划线将点连接起来。现在需要用钢笔连线使得所有的点都连通,并使用墨水最少,画线使用墨水的值等于线的长度。 分析: 很明显是要求其最小生成树。在每两个点之间建边,长度为其之
洛谷 Problem P1629 - 邮递员送信 原题地址 题目类型:最短路径、Dijkstra 题意: 在一个有向图中,给定一个起点,对于其余的每个点进行从起点走到该点再返回起点的操作,求最终经过的总路程。 分析: 首先可以想到用 Dijkstra 算法求出从起点到各个点的最短距离,但是到达每个点后还要返
/** * This problem was asked by Twitter. Implement an autocomplete system. That is, given a query string s and a set of all possible query strings, return all strings in the set that have s as a prefix. For example, given the query string de and the set
传送门 看到排列,容易尝试连 \(i \rightarrow p_i\) 有向边。最后会形成若干个简单环(当然也有可能有 \(i\rightarrow i\) 的环)是众所周知的。 把点集分成两部分:\([1,n]\) 的点称为黑点,\([n+1,n+m]\) 的称为白点。 则每次操作,在图上看,就是选择两个异色点 \(i,j\),然后: 断开 \(i\righ
咕咕咕~~ [P3803 【模板】多项式乘法(FFT)](https://www.luogu.com.cn/problem/P3803)(MODULE + FFT)[P1919 【模板】A*B Problem升级版(FFT快速傅里叶)](https://www.luogu.com.cn/problem/P1919)(MODULE + FFT + 高精度乘法)[P2553 [AHOI2001]多项式乘法](https://www.luogu.
题目描述: 输入: 6 8 输出: 6 8 思路: 递归+回溯的应用 参考代码: #include<iostream> #include<string.h> using namespace std; //判断素数 int is_prime(int x) { //除1和其本身外,不能被其他整数所除. 一般因子i <= 根号x i*i<= x for(int i = 2; i * i <= x; i
简单哈希 + 反向建图 前向星或者邻接都可 为什么反向? 由结论推原因,当确定一个状态就不可改了,以为这样才是最优 #include <iostream> #include<algorithm> #include<cstdio> #include<vector> #include<queue> using namespace std; #define ll long long co
题目链接 题目思路 二分答案 然后贪心check 这个贪心有点意思 代码 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; #define fi first #define se second #define debug printf("aaaaaaaaaaa\n"); const int maxn=3e5+5,inf=0x
#include<iostream> #include<algorithm> #include<math.h> #include<string.h> using namespace std; int x[1002]={0},y[1002]={0},sum[1002]={0}; int main(){ int T; cin>>T; for(int k=1;k<=T;k++){ char a[1002],b[10002]; for
Wavebee SDK was designed for ubuntu16, not compatible with Ubuntu 20. Solution: install libssl1.0-dev link: https://www.garron.me/en/linux/install-ruby-2-3-3-ubuntu.html Edit this file /etc/apt/sources.list and add this line to the end of it. deb http://s