摘要: head 表示单链表的头 cnt 表示 数组坐标 const int N = 1e6 +10; int e[N],ne[N]; //e[N]表示该数组节点存储的值的大小,ne[N]表示该数组节点后续节点的坐标 void init()/*初始化*/{ head = -1;// 后续节点为-1的表示这是 阅读全文
posted @ 2020-10-27 19:17 爱努力的人最幸福 阅读(118) 评论(0) 推荐(0)
摘要: upper_bound函数返回数组队列中第一个大于x的数组位置,要是想知道x的数组下标,需要减去数组a的地址 前提是数组已经排好序 int k = upper_bound(a,a+n,x)-a;//k表示a数组中第一个大于x的数值的数组下标 lower_bound函数返回数组中第一个大于等于x的数组 阅读全文
posted @ 2020-10-15 17:51 爱努力的人最幸福 阅读(206) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std;const int N = 1010;int n,m;int f[N][N];char a[N],b[N];int main(){ cin>>n>>m; scanf("%s",a+1); scanf("%s",b+1); f 阅读全文
posted @ 2020-10-11 21:05 爱努力的人最幸福 阅读(84) 评论(0) 推荐(0)
摘要: #include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std; int exgcd(int a,int b,int &x,int &y){ if(!b){ x=1,y=0; retu 阅读全文
posted @ 2020-10-11 16:06 爱努力的人最幸福 阅读(59) 评论(0) 推荐(0)
摘要: int prime[N],cnt; bool st[N]; void get_prime(int n){ for(int i=2;i<=n;i++){ if(!st[i]) prime[cnt++]=i; for(int j=0;prime[j]*i<=n;j++){ st[prime[j]*i]= 阅读全文
posted @ 2020-10-11 15:29 爱努力的人最幸福 阅读(87) 评论(0) 推荐(0)
摘要: 树状数组的特点: 1. 可以修改某个点的值 2. 区间修改 int lowbit(int x){ return x&-x;} 这个函数的作用主要是求x能整除2的几次幂 给定 nn 个数组成的一个数列,规定有两种操作,一是修改某个元素,二是求子数列 [a,b][a,b] 的连续和。 输入格式 第一行包 阅读全文
posted @ 2020-10-09 20:40 爱努力的人最幸福 阅读(89) 评论(0) 推荐(0)
摘要: 首先通过分析动态规划得到状态转移方程 f[i]=max(f[1],...,f[k],..f[i-1])+1; 具体代码: #include<iostream>using namespace std;const int N = 1010;int n;int f[N];int a[N];int main 阅读全文
posted @ 2020-10-04 20:59 爱努力的人最幸福 阅读(115) 评论(0) 推荐(0)
摘要: 通过求最大公约数去求 阅读全文
posted @ 2020-10-01 19:54 爱努力的人最幸福 阅读(80) 评论(0) 推荐(0)
摘要: #include<iostream>#include<algorithm>using namespace std; int n; //求a^k mod p 的结果long long pmi(int a,int k,int p){ long long res=1; while(k){ if(k&1) 阅读全文
posted @ 2020-10-01 17:03 爱努力的人最幸福 阅读(109) 评论(0) 推荐(0)
摘要: #include<iostream>#include<cstring>#include<algorithm>using namespace std;long long res; int prime[1000010];//存储质因数int PII[1000010];//存储欧拉函数bool stu[1 阅读全文
posted @ 2020-10-01 16:08 爱努力的人最幸福 阅读(120) 评论(0) 推荐(0)