摘要:#include #define FRER() freopen("i.txt","r",stdin); using namespace std; /* ac自动机 我们考虑两个串的连接处,对于文本串,如果在t[i]匹配了x个,那么说明以 t[i]为结尾的串有x,反着找val[t[i]],说明以t[i]为结尾的串有x,记录乘积 来反应最终有多少贡献值 傻逼了,把int ch,弄成char ch了...
阅读全文
摘要:题意:给你n+1个点,让你剩下m+1个点 。 删除的方法是,取出来构成最小三角形的中间点,去除那个点,最后输出去除点的顺序。 解法:先求出来每个三角形的面积,用set 排序或者用优先队列 都OK 每次取出来最小值Pop 并且更新左右点 两端点需要特殊处理下
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=2e5+100; char s[maxn]; /* 这个字符不是随便可以加的,因为会出现,你加了一个字符 使左边的最小值往右边移了一下,但是导致最右边往右移了,得不偿失 首先我们考虑垂直方向,我们假设它在0这个位置,那么他所移动的 位
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; /* 这道题的难点在于怎样加x或者y才能使的a转化为b,并且加的x和y的和最少 这道题竟然用了floyd,转换成求最短路 这才深刻地体会到,我根本不会算法 */ const int maxn=10; const int INF=0x3f3f3f3f; int dis[maxn][maxn]; int num
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; /* 给你一个数n,让你求一个串,里面的子序列“1337”的数量恰好为n 开始时用1的数量*C(m,2)*7的数量,不好处理 题解中用13377773333337的形式,使得C(m,2)+7的数量=n; 这样更好处理 */ typedef long long ll; const int maxn=1e9;
阅读全文
摘要:#include #define inf 0x3f3f3f3f using namespace std; /* 一道dp题,看来自己还是需要继续努力呀 dp[i]表示的是1-i个时间,所能够完美表示的2轮的车有多少个 状态转移 满足条件 dp[i]=dp[i-2]+1 dp[i]=dp[i-3] 并且如果dp[i-2]+1!=dp[3],说明有多种情况,虽然能够分好 */ int a[3500...
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; /* 直接针对平方来找 每次走的是个折线 */ pair<int,int> work(int x) { int y=(int)sqrt(x*1.0+0.5); pair<int,int>ans; if(y&1&&y*y==x) { ans.first=ans.second=(-(y-1)>>1); retur
阅读全文