Acwing

AcWing 777. 字符串乘方

AcWing 777. 字符串乘方 1. 地址 https://www.acwing.com/problem/content/779/ 2. 题解 #include <iostream> #include <cstdio> using namespace std; /* 算法思路: 通过本题性质,我 ......
乘方 字符串 字符 AcWing 777

AcWing 776. 字符串移位包含问题

AcWing 776. 字符串移位包含问题 1. 地址 https://www.acwing.com/problem/content/778/ 2. 题解 #include <iostream> #include <cstdio> #include <string> #include <algori ......
字符串 字符 AcWing 问题 776

AcWing 771. 字符串中最长的连续出现的字符

AcWing 771. 字符串中最长的连续出现的字符 1. 地址 https://www.acwing.com/problem/content/description/773/ 2. 题解 #include <iostream> #include <cstdio> #include <string> ......
字符 字符串 AcWing 771

Acwing周赛102

倍增 这是一道简单数论题 using namespace std; typedef long long LL; const int N = 1e5 + 10; int a[N], n; int div(int x) { if(x % 2 == 0) while(x % 2 == 0) x /= 2; ......
Acwing 102

AcWing 770. 单词替换

AcWing 770. 单词替换 1. 地址 https://www.acwing.com/problem/content/772/ 2. 题解 #include <iostream> #include <cstdio> #include <sstream> using namespace std; ......
单词 AcWing 770

POJ2739 Sum of Consecutive Prime Numbers&&Acwing4938 连续质数之和

方法:单调队列 为什么是单调队列?因为这里让我们求连续的质数和,我们可以利用欧拉筛来维护质数,再利用单调队列来维护连续的质数。 代码( ~~POJ 不支持 C++ 11 差评~~): #include<cstdlib> #include<cstring> #include<cstdio> #incl ......
质数 之和 Consecutive amp Numbers

acwing 4645. 选数异或

输出yes no yes no 题意分析,给一串数组,再在每次提问时给出一个区间,l,r; 求l,r区间内是否存在两个数,两数异或后值为给出的x; 已知a^b=x-->a^x=b; 思路:1,把每个数异或x,存在另一个数组(b)里,暴力搜索,看区间内b数组内数字是否有等于a数组内数字,TLE 2.记 ......
acwing 4645

AcWing 3549. 最长非递减子序列

$AcWing$ $3549$. 最长非递减子序列 一、题目描述 给定一个长度为 $n$ 的数字序列 $a_1,a_2,…,a_n$,序列中只包含数字 $1$ 和 $2$。 现在,你要选取一个区间 $l,r$,将 $a_l,a_{l+1},…,a_r$ 进行翻转,并且使得到的新数字序列 $a$ 的最 ......
序列 AcWing 3549

AcWing 1209. 带分数

1-暴力解法 思考1:暴力列举出1~9的全排列,之后再将这些数字按照一定规则相加,最后将结果与n比较。全排列好写,但相加的规则不好写,而且太暴力了,估计会超时。 /* AcWing 1209. 带分数 00.最暴力的写法 1.枚举全排列 2.枚举位数(枚举a和b,可算出c) 3.直接算出n,判断等式 ......
带分数 AcWing 1209

AcWing 756. 蛇形矩阵

AcWing 756. 蛇形矩阵 1. 地址 https://www.acwing.com/problem/content/description/758/ 2. 题解 #include <iostream> #include <cstdio> using namespace std; //通过四个 ......
蛇形 矩阵 AcWing 756

AcWing 754. 平方矩阵 II

AcWing 754. 平方矩阵 II 1. 地址 https://www.acwing.com/problem/content/756/ 2. 题解 #include <iostream> #include <cstdio> #include <cmath> using namespace std ......
矩阵 AcWing 754 II

AcWing 753. 平方矩阵 I

AcWing 753. 平方矩阵 I 1. 地址 https://www.acwing.com/problem/content/755/ 2. 题解 #include <iostream> #include <cstdio> #include <cmath> using namespace std; ......
矩阵 AcWing 753

AcWing 727. 菱形

AcWing 727. 菱形 1. 地址 https://www.acwing.com/problem/content/description/729/ 2. 题解 #include <iostream> #include <cstdio> #include <cmath> using namesp ......
菱形 AcWing 727

AcWing 726. 质数

AcWing 726. 质数 1. 地址 https://www.acwing.com/problem/content/728/ 2. 题解 // 此题跟完全数这道题差不多 #include <iostream> #include <cstdio> #include <cmath> using na ......
质数 AcWing 726

AcWing 725. 完全数

AcWing 725. 完全数 1. 地址 https://www.acwing.com/problem/content/description/727/ 2. 题解 #include <iostream> #include <cstdio> #include <cmath> using names ......
全数 AcWing 725

AcWing 4086 分糖果

关于这道题我当时大意了 https://www.acwing.com/problem/content/description/4089/ 关于我的某个变量没有初始化这件事,唯一想法,敲死得了,谁懂? 其实就是一道简简单单的数学分析题,和大佬们不一样,萌新只会简简单单的小学数学(本人初二!) 分析走起 ......
糖果 AcWing 4086

AcWing 656. 钞票和硬币

AcWing 656. 钞票和硬币 1. 地址 https://www.acwing.com/problem/content/658/ 2. 解答 #include <iostream> #include <cstdio> using namespace std; int main(){ int m ......
硬币 钞票 AcWing 656

AcWing 242. 一个简单的整数问题 / 树状数组区间修改区间查询模板题

AcWing 242. 一个简单的整数问题 // 实例化是抽象的天敌,是抽象的克星 // 通过公式 sn = (i 从 1 ~ n 求积) di * (1 + n) - (i 从 1 ~ n 求积) i * di // 来计算前缀和, 又 (i 从 1 ~ n 求积) i * di 不能由 (i 从 ......
区间 整数 数组 模板 AcWing

AcWing 241. 楼兰图腾 / 树状数组 + 在线隔离数据 + 变为 1 统计和

AcWing 241. 楼兰图腾 #include <iostream> #include <cstring> using namespace std; const int N = 2e5 + 10; typedef long long LL; int n, a[N], tr[N]; LL high ......
数组 图腾 数据 AcWing 241

Acwing 3728-城市通电 / 最小生成树,建图,超级源点

AcWing 3728. 城市通电 做出来就凭之前的一句感悟:把每个动态选择变为与超级源点连的一条边,把这条边加入图里面跑最小生成树就相当于考虑了每个动态选择 ......
通电 Acwing 城市 3728

AcWing 788 逆序对的数量

788. 逆序对的数量 - AcWing题库 逆序对,即位置顺序与大小顺序不符的数对,也就是对于一个期望升序的序列Num[],当i<j时,Num[i]>Num[j] 这道题要求求出逆序对的个数,显然在归并排序的过程中我们就是在逐步的消除逆序对,所以我们可以在递归的排序过程中求出逆序对的个数 已知归并 ......
逆序 数量 AcWing 788

Acwing 3696-构造有向无环图 / 拓扑排序 / 指定无向边的方向,让其和有向边一起构造成一个拓扑图

Acwing 3696-构造有向无环图 开始想了半天没想明白,后来突然想到这个题目这个名称,或许是一个模板题。我不知道是不是模板题,但我当模板题记下来,因为我理解不了。 操作: 1. 读边时有向边指向的点入度增加,无向边入度都为 0, 用结构体存下所有无向边 2. 进行一次 top_sort,只要点 ......
拓扑 拓扑图 方向 Acwing 3696

AcWing 245. 你能回答这些问题吗

给定长度为 N 的数列 A,以及 M 条指令,每条指令可能是以下两种之一: 1 x y,查询区间 [x,y] 中的最大连续子段和, 2 x y,把 A[x]改成 y。 对于每个查询指令,输出一个整数表示答案。 输入格式 第一行两个整数 N,M。 第二行 N 个整数 A[i]。 接下来 M 行每行 3 ......
AcWing 问题 245

AcWing 1275. 最大数

给定一个正整数数列 a1,a2,…,an,每一个数都在 0∼p−1之间。 可以对这列数进行两种操作: 添加操作:向序列后添加一个数,序列长度变成 n+1; 询问操作:询问这个序列中最后 L 个数中最大的数是多少。 程序运行的最开始,整数序列为空。 一共要对整数序列进行 m 次操作。 写一个程序,读入 ......
AcWing 1275

AcWing 可达性统计(bitset

可达性统计 建图 图的存储 拓扑排序: DAG(有向无环图),往拓扑排序思考。 拓扑排序的目标是将所有节点排序,使得排在前面的节点不能依赖于排在后面的节点。 此类问题需要使用bitset优化。 bitset 在 bitset 头文件中,它类似数组,并且每一个元素只能是0或1,每个元素只用1bit空间 ......
可达性 AcWing bitset

逆序对的数量(Acwing)

1.首先要想到排序问题中的归并排序来解决此问题; 其次我们要看逆序数的定义是i<j&&a[i]>a[j] ; 下面就来模拟一下; 1 3 2 4 7 8 9 5 6 7 ......
逆序 数量 Acwing

AcWing 第 98 场周赛 ABC

https://www.acwing.com/activity/content/competition/problem_list/3128/ ###4947. 大整数 题目大意: 给定n,k。输出n个k。 输入样例: 3 2 输出样例: 222 #include<bits/stdc++.h> usi ......
AcWing ABC 98

acwing2816. 判断子序列

link code #include<bits/stdc++.h> using namespace std; const int N = 100010; int a[N],b[N]; int main(){ int n, m; cin >> n >> m; for(int i = 1; i <= n ......
序列 acwing 2816

区间合并 acwing803

link code #include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int n; int ans = 1, tpr = 0; vector<pair<int,int>>v; int l, r ......
区间 acwing 803

AcWing算法提高课-1.1.1摘花生

题目描述 Hello Kitty想摘点花生送给她喜欢的米老鼠。 她来到一片有网格状道路的矩形花生地(如下图),从西北角进去,东南角出来。 地里每个道路的交叉点上都有种着一株花生苗,上面有若干颗花生,经过一株花生苗就能摘走该它上面所有的花生。 Hello Kitty只能向东或向南走,不能向西或向北走。 ......
花生 算法 AcWing