摘要:学后缀数组快学死我了,学了三天,才懂了点大概,那命做了个模板题,然后推荐一个好的后缀数组博客https://blog.csdn.net/j_sure/article/details/41777097#就是它救了我的命
阅读全文
摘要:#include #include #include #include #include using namespace std; const int maxn=10000+100; int n,m; int cnt; vector g[maxn]; struct note { int v; int num; bool operator p.num||num==...
阅读全文
摘要:反着存图,太tm神了......看了我一晚上才懂
阅读全文
摘要:#include #include #include #include using namespace std; const int maxn=20; int g[maxn][maxn]; int vis[maxn]; int n,cnt; int cacl(int x) { return x==0?0:(cacl(x/2)+(x&1)); } bool two(int x)//...
阅读全文
摘要:打乱的连续序列,想要变成上升序列的话,每次交换前两个数字,使a1<a2,并把a1放在最后面,直到a1为n,a2为1。这里倒着来就可以了.
阅读全文
摘要:#include #include #include #include using namespace std; const int maxn=100+10; int t; string s1,s2; int main() { scanf("%d",&t); for(int Case=1; Case> s1 >> s2; int snum=0,tnum=0...
阅读全文
摘要:O(n)=O(n-2)+2^(n-3),大数高精度
阅读全文
摘要:写出前几个样例,发现是斐波那契数列,这里要用高精度大数写
阅读全文
摘要:#include #include #include #include #include using namespace std; typedef long long ll; map mmp; int t,n; ll x; ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); } int main() { scanf("%d",&t...
阅读全文
摘要:#include #include #include #include using namespace std; typedef long long ll; const int maxn=300+10; ll dp[maxn][maxn]; ll sum[maxn][maxn]; int m,n; int gcd(int a,int b) { return b==0?a:gcd(...
阅读全文
摘要:简单期望,还是能做出来的,过河时间就是l/v和3l/v之间,即2l/v,再加一下D-sum(l)就可以了
阅读全文
摘要:从大到小放,最后放最小的,dp[i-1][l-1][r]放最左边,dp[i-1][l][r-1]放最右边,dp[i-1][l][r]*(ll)(i-2)放在i-1块之间。。。。。。。肯定不是我想出来的啊!看的紫书上的思路, 递推太tm难了,我推了3个题,连样例都过不了。。。。。。。。。QAQ,怎么办
阅读全文
摘要:同对m和n的每一项用唯一分解定理,比较次数,比m大则m是i的约数,否则不是,是约数,则无关
阅读全文
摘要:#include #include #include #include #include #include using namespace std; double dp[6][6][6][6][6][6][6][6][6]; bool vis[6][6][6][6][6][6][6][6][6]; vector vv[10]; double d(int w1,int w2,int w...
阅读全文
摘要:感觉有点树形dp的感觉,就是假设a子树及a的点的数量为u,那么a子树之外点的数量就为n-u,使经过边的次数最多,就是min(u,n-u),再乘以到a的权值就可以了。
阅读全文
摘要:sum[x]+num[y]*z>sum[y]+num[x]*z贪心更新父节点
阅读全文
摘要:二分图可以去处理一对多,或多对一但只统计为数量为1的问题。这里是多个横坐标对应一个纵坐标,但只取1。这个题我写完后想到了2-set。老了啊,多长时间没写二分图,连板子都记错了。
阅读全文
摘要:看是否存在一个环,使所有点都在此环内,并使权值最小。所有点在环内即父节点单一,所拆点建立二分图,只要最后通量为n,那么所有点就都能经过一遍,就符合上述情况。
阅读全文