自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(45)
  • 问答 (1)
  • 收藏
  • 关注

原创 无题。。。

①CF1042B Vitamins:一个简单的dp加二进制状压的题目~~https://codeforces.com/problemset/problem/1042/B大意:数据有n组数,每组数有一个价值cic_ici​和一个字符串S,字符串S中包含3个字母A,B,C,问集齐ABC三个字母的最小价值(一个字母可以有多个)ps:由于很简单,是可以记录数据之类的做出来的,但是要练习dp嘛,所以写了下dp的写法利用二进制表示不同的状态001 C010 B011 BC100 A101 AC110

2021-07-08 17:51:18 407 5

原创 ggiohokbih

hiooi

2022-06-08 13:17:32 388 1

原创 11111111

const ll int maxn = 4e5 + 205;int v[maxn*10];ll jc[maxn]= {0},inv[maxn]= {0};vector<int> prime;void euler(){ for(int i = 2; i <maxn ; ++ i) { if(!v[i]) { v[i] = i; prime.push_back(i); }

2022-04-11 23:25:52 311

原创 ICPC Nanjing 2021 H, Crystalfly

#include<bits/stdc++.h>using namespace std;#define ll long longinline char gc(){ static char buf[1000000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;}#define gc getcharinline ll re

2022-02-27 13:18:35 357

原创 树形dp(每天一道,舒舒服服)

二叉苹果树~~~#include<bits/stdc++.h>using namespace std;#define ll long long#define bug(x) cout<<#x<<"=="<<x<<endl;const ll maxn=1e5+10;struct node{ int to,next; int w;}edge[maxn*2];int head[maxn] = { 0 };int tot=

2021-10-11 19:34:54 119 3

原创 概率DP(每天一道 舒舒服服~)

hhhh#include<bits/stdc++.h>using namespace std;const int maxn=1e5+10;#define bug(x) cout<<#x<<"=="<<x<<endl;double dp[1005][1005];struct node{ double yd; double ydx; double ydy;}a[1005][1005];int main(){

2021-10-10 09:55:09 79 1

原创 LCS的特殊问题(Hills And Valleys Gy)

#include<bits/stdc++.h> #include <iostream> #include<cstdio> #include <map> #include<cstring> using namespace std; #define ll long long #define bug(x) cout<<#x<<"=="<<x<<end.

2021-10-09 13:28:48 76

原创 有博客了!!!

看我的文章请转至网站:ximena.top

2021-09-14 16:37:45 65 1

原创 P1174(dp)

先对这个矩阵进行预处理,将每一列分成n块,每一块以n为开头,这样子便于后续计算#include<bits/stdc++.h>using namespace std;typedef long long ll;typedef pair<int, int> P;const int INF = 0x3f3f3f3f;const int N = 210;const int MOD = 998244353;const double eps = 1e-10;#define bug

2021-09-08 16:16:28 56

原创 字符串(板子)

tire树#include <bits/stdc++.h>using namespace std;#define ll long longconst ll int maxn = 4e6+10;const ll int N = 1e5+10;#define bug(x) cout<<#x<<"=="<<x<<endl;string a;int tree[maxn*4][30]={0};int way1[maxn*4] = { 0 }

2021-08-25 10:38:15 164

原创 博弈论论论

找规律Roy&October之取石子链接:https://www.luogu.com.cn/problem/P4018①当n属于1~5的时候,先手必胜1(题目意义下的质数),2,3,54= 2 ^2②当n为6的时候,先手无论怎么取 剩下的都是1~5转化为第一种情况,所以后手必胜③当n为12的时候,先手取t(t属于1~5)的时候,后手可以取6-t个,转化为第二种情况,后手再次必胜。我们发现 当n为6的倍数的时候,后手为必胜态。当n不为6的倍数的时候,先手可以取t个后将n转换为6的倍数

2021-08-16 10:51:09 70

原创 [CCC 2016]生命中的圆

fi,j​=fi−1,j−1​⊕fi−1,j+1​,其中⊕\oplus⊕表示异或不难推出结论:f [i] [j]=f[ i− 2^k ] [j−2^k ] ⊕ f[ i− 2^k ] [j+2^k ];#include<bits/stdc++.h>#define bug(x) cout<<#x<<" == "<<x<<endl;#define ll long longusing namespace std;const int

2021-08-16 10:07:19 90

原创 P1108 低价购买

求最长下降子序列的个数,注意完全相同的序列不重复计算#include <bits/stdc++.h>#define INF 0x3f3f3f3f#define ll long long#define speed(x) ios::sync_with_stdio(false), cin.tie(x), cout.tie(x)#define bug(x) cout << #x << " == " << x << '\n'const ll in

2021-08-13 20:12:41 49

原创 [HAOI2011]向量(数论,gcd,裴蜀定理)

定理的具体内容:若 a , b a,b a,b 是整数,且 gcd ⁡ ( a , b ) = d那么对于任意的整数 x,y,ax+by 都一定是 d 的倍数,特别地,一定存在整数 x,y,使 a x + b y = d ax+by=d ax+by=d 成立。 k(a,b)+q(b,a)+w(a,−b)+c(b,−a)=(x,y) --------->(k+w)a+(q+c)b=x,(k−w)b+(q−c)a=y所以如果想要 (k+w),(q+c)(k-w),(q-c)有整数解 需要

2021-08-13 09:36:15 152

原创 莫队(板子)

根据所求更改 add,del,answer就好#include <bits/stdc++.h>using namespace std;typedef long long ll;#define bug(x) cout<<#x<<" == "<<x<<endl;const int maxn = 3e3+5;ll mod = 1e6+7;///const ll int INF=0x3f;int a[maxn] = { 0 };int

2021-08-11 10:16:52 84

原创 lca板子

#include<bits/stdc++.h>using namespace std;const int N=5e5+10;int head[N];int n,m,s,f[N][30],lg[N],h[N];///该结点的深度///f[i][j]为i结点向上2^j的祖先struct node{ int to,ne;}bian[N*2];int tot = 0;void add_edge(int x,int y){ tot++; bian[tot].to

2021-08-06 10:55:12 227 3

原创 牛客多校5

D题:题目大意:就是找了两个等长的子序列字符串 aa,bbaa<bb一个字符串大于另一个字符串两种情况:首字母a[1]<b[1]前面几个字母都相同:然后第i个字母a[i]<b[i]所以我们只需要比较每一个字母a[i]<b[j]的时候www为计算 a[1~i-1]和b[1-j-1]有多少相等子序列(通过dp求)ans为a[i+1 ~ a.length()]与b[j+1 ~b.length()]可以组合出多少相同长度子序列设n=a.length( )-(i+1),m=

2021-08-01 13:40:45 123

原创 牛客多校三

B:很容易可以分析出来就是要在每一行 列里面最大程度上挑最小的连接起来,但是一直不知道怎么实现 我和队友的愚蠢for循环只能实现行的最优或者列的最优(后续有想过都挑出最小的,但是如果行列的最小项相同就要选次小了 彻底懵圈),然后一起悲伤wa了QwQ今天大家都是爆零人 但是爆零人永不言弃!!!!用最小生成树连接即可。几个优秀的写法:①通过向量的存储,就不需要排序了。因为权值的范围是固定的!②通过n+J使行和列代表的点值分开 类似操作有好多比如10*j之类的 主要是处理后的j的映射范围不和i冲突就好啦

2021-07-24 20:24:43 133 2

原创 拓扑排序 链式前向星

链接:https://www.luogu.com.cn/problem/P4316打个板子给自己看~#include <bits/stdc++.h>using namespace std;#define ll long long#define bug(x) cout << #x << " == " << x << endl;#define INF 0x3f3f3f3f3f3f3f3f#define inf 0x3f3f3fconst

2021-07-24 09:11:32 135

原创 Mr. Kitayuta‘s Technology(dfs,连通块)

链接:https://codeforces.com/problemset/problem/505/D发现一道有趣的题目大意:就是连城市的每个点要用最少的路来满足m个条件给出的条件会把n个点分块 所以可以利用并查集来记录连通在一起的点可是并查集是体现不了单向边的惹 ->利用vector来记录嘛,就像最小生成树的板子一样连通块最多有两种可能①一种是无环的最小生成树形式->n-1②一种有环->n所以我们可以用dfs搜索看看有没有重复遍历的点就好这个地方是一个大糊点!!!可以设

2021-07-23 16:51:46 121

原创 lucas定理 给自己打个板子!

定理很有用C(n,m)=C(n%mod,m%mod)*C(n/mod,m/mod);#include<iostream>#include<cstdio>using namespace std;#define ll long longconst ll int MAX_N = 1e5 + 10;#define bug(x) cout<<#x<<" == "<<x<<endl;ll mod ;ll a[MAX_N]= {0}

2021-07-22 15:33:24 85

原创 快读,快速幂,龟速乘

自己总结下#include <bits/stdc++.h>using namespace std;const int maxn = 1e6 + 5;int a[maxn] = { 0 };int c[maxn] = { 0 };#define ll long long#define bug(x) cout<<#x<<" == "<<x<<endlll n,m,l;ll mod=1e10+7;void read(ll &a

2021-07-20 19:31:31 69

原创 2021牛客多校训练2

k题(模拟)#include <bits/stdc++.h>using namespace std;const int maxn = 1e6 + 5;int n, b[maxn];int ans[maxn]={0};int main(){ int n,m; scanf("%d %d",&n,&m); for(int i=1;i<=m;i++) { int pos,x; scanf("%d %d",

2021-07-19 19:03:29 72 3

原创 树状数组..

操作1:遍历每一个包含元素a[i]的父亲结点int lowbits(int index){ return index & (-index);}////加个循环就好操作二:修改每一个父亲结点由于元素a[i]而要修改的值void add(int index, int y){ for (int i = index; i <= n; i += lowbits(i)) { c[i] += y; }}操作三:算出前缀和int getsu

2021-07-19 10:17:28 67

原创 P2331 [SCOI2005]最大子矩阵(dp,前缀和)

注意:子矩阵可以是空!!!dp[i][j][num]代表第一排前i个,第二排前j个,取num个矩阵最大权值而m等于1的情况等价于第二排权值都是0三种情况:第num个矩阵从第一排取第num个矩阵从第二排取第num个矩阵是两排的感觉很有趣~#include<cstdio>#include<algorithm>using namespace std;const int N=110;const int M=11;int n,m,K,sum1[N]={0},sum2[

2021-07-18 23:05:16 64

原创 2021牛客暑期多校训练营1

A博弈(sg函数)sg函数看这一篇特别清楚->链接:https://blog.csdn.net/strangedbly/article/details/51137432题目大意就是两个人拿石头,两堆石头,每次操作必须一堆拿k个(k>=1),另一堆拿sk个(s>=0),谁先把石头拿光谁胜利Alice为先手很明显可以看出来①如果是一堆为0的情况,另一堆为k个。先手必胜②一堆是另一堆的倍数。先手必胜③先手拿石头后,状态变为后手必胜的状态,那么先手必胜e.g:一堆为i,一堆为j后手

2021-07-18 17:23:12 145 3

原创 race(数论,组合,递推)

链接:https://vjudge.net/problem/UVA-12034First:首先我们可以根据紫书上的思路来设n个人的名次可能为f(n)假设第一名有i个人,i个人是第一名的组合是C(n,i)后面的n-i个人就是f(n-i)所以f(n)=C(n,1)f(n-1)+C(n,2)f(n-2)+…+C(n,n)f(0)所以最后一项为前n个人并列第一名C(n,n)为1要提前设置为f(0)为1结果我发现这样子会爆long long 而且在计算组合数的时候我利用了公式C(n,k+1)=(n-k

2021-07-14 14:15:05 202 1

原创 Jessica‘s Reading Problem(尺取)

无他 尺取就好#include<iostream>#include<cstdio>#include<map>using namespace std;#define INF 0x3f3f3f3ftypedef long long ll;typedef unsigned long long ull;#define speed(x) ios::sync_with_stdio(false), cin.tie(x), cout.tie(x)#define bug(

2021-07-14 11:19:14 43

原创 D.Deleting Divisors(博弈)

题目大意:Alice和Bob玩游戏,Alice先手,每一次他们都要做操作就是将数减去它的因子(他小于自身且不为1的因子)轮到谁不能做这个操作谁就输了。所以他们会尽力给对方留下质数链接: https://codeforces.com/problemset/problem/1537/D.#include<bits/stdc++.h>using namespace std;#define INF 0x3f3f3f3ftypedef long long ll;typedef unsigne

2021-07-13 19:38:27 409

原创 一个数的约数和,约数个数问题

一个数的约数个数#include<bits/stdc++.h>using namespace std;#define INF 0x3f3f3f3ftypedef long long ll;typedef unsigned long long ull;#define speed(x) ios::sync_with_stdio(false), cin.tie(x), cout.tie(x)#define bug(x) cout << #x << " == " &

2021-07-13 18:27:03 85

原创 D. PriceFixed(贪心)

链接: https://codeforces.com/problemset/problem/1539/D.#include<bits/stdc++.h>using namespace std;#define INF 0x3f3f3f3ftypedef long long ll;typedef unsigned long long ull;#define speed(x) ios::sync_with_stdio(false), cin.tie(x), cout.tie(x)#def

2021-07-13 10:21:56 137

原创 Probability|Given (概率)

把在n个人中m个人买了东西的总概率算出来用dfs搜索每一种情况就好#include<bits/stdc++.h>#define INF 0x3f3f3f3f#define ll long long#define speed(x) ios::sync_with_stdio(false), cin.tie(x), cout.tie(x)#define bug(x) cout << #x << " == " << x << '\n';con

2021-07-12 19:06:07 233

原创 Send a Table (欧拉函数)

#include<bits/stdc++.h>#define INF 0x3f3f3f3f#define ll long long#define speed(x) ios::sync_with_stdio(false), cin.tie(x), cout.tie(x)#define bug(x) cout << #x << " == " << x << '\n';const ll int MAX_N = 3e6 + 5;using na

2021-07-12 16:44:00 134

原创 C. AquaMoon and Strange Sort

链接: https://codeforces.com/contest/1546/problem/C.QwQ一觉醒来fst竟是我自己很容易可以看出来操作数只和这个元素移动的距离有关如果是移动距离是偶数,交换操作数就抵消了,这样子最后方向还是right。因此我们分下标是奇偶进行讨论。分成奇数组和偶数组并排序,这样子下标是奇数的就移动到了奇数位,下标是偶数的就移动到了偶数位,最后把两个数组交替合并,最后看看满不满足数组单调不下降即可#include<bits/stdc++.h>#define

2021-07-12 10:13:44 438

原创 唯一分解定理

题目Bi-shoe and Phi-shoehttps://vjudge.net/problem/LightOJ-1370一个简单的欧拉筛就完事啦!#include<iostream>#include<algorithm>#include<cstdio>using namespace std;#define ll long long#define bug(x) cout << #x << " == " << x &lt

2021-07-09 13:51:57 50

原创 研究dping....

想象了一个题目,一个数组中能不能选X个元素的和恰好为sum。#include <bits/stdc++.h>using namespace std;#define bug(x) cout<<#x<<" == "<<x<<'\n'#define ll long longconst int MAX_N=2e3+10;int a[MAX_N] = { 0 };int dp[100005]= {0};int32_t main(){

2021-07-07 20:53:11 118

原创 Number of Pairs(思维)

链接:https://codeforces.com/contest/1538/problem/C大意:查找有多少对ai与aj之和在区间[l,r];每一个a[i]查找在小于a[i]的范围中有多少个数满足这个条件即可。#include <bits/stdc++.h>using namespace std;/*#define rapido \ ios_base::sync_with_stdio(false); \ cin.tie.

2021-07-07 16:07:38 579

原创 食物链(带权并查集)

动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述:第一种说法是"1 X Y",表示X和Y是同类。第二种说法是"2 X Y",表示X吃Y。此人对N个动物,用上述两种说法,一句接一句地说出K句话,这K句话有的是真的,有的是假的。当一句话满足下列三条之一时,这句话就是假话,否则就是真话。1) 当前的话与前面的某些真

2021-07-04 21:26:56 154

原创 P2671 [NOIP2015 普及组] 求和

题目描述一条狭长的纸带被均匀划分出了nnn个格子,格子编号从111到nnn。每个格子上都染了一种颜色color_icolor_icolor_i用[1,m][1,m][1,m]当中的一个整数表示),并且写了一个数字number_inumber_inumber_i。定义一种特殊的三元组:(x,y,z)(x,y,z)(x,y,z),其中x,y,zx,y,zx,y,z都代表纸带上格子的编号,这里的三元组要求满足以下两个条件:xyz是整数,x<y<z,y−x=z−ycolor-x=color-z

2021-05-24 19:59:31 148

原创 P1658 购物(贪心算法)

P1658 购物提交 2.48k通过 1.16k时间限制 1.00s内存限制 125.00MB题目描述你就要去购物了,现在你手上有N种不同面值的硬币,每种硬币有无限多个。为了方便购物,你希望带尽量少的硬币,但要能组合出1到X之间的任意值。输入格式第一行两个数X、N,以下N个数,表示每种硬币的面值。【数据规模】对于30%的数据,满足N≤3,X≤20;对于100%的数据,满足N≤10,X≤1000.输出格式最少需要携带的硬币个数,如果无解输出-1.输入输出样例输入 #120 4

2021-05-20 17:56:24 511

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除