摘要:
求两段不相交子序列,他们异或和的 和最大 #include<iostream> #include <algorithm> #include <cstring> using namespace std; const int N =4e5+4; int ch[N*32][2],ans; int tot= 阅读全文
posted @ 2023-02-26 20:56
towboat
阅读(37)
评论(0)
推荐(0)
摘要:
从序列A中选出两个进行异或运算,得到的结果最大是多少? 两个数二进制插入Trie 每次遍历时尽量走反 #include<iostream> #include <algorithm> #include <cstring> using namespace std; const int N =1e5+4; 阅读全文
posted @ 2023-02-26 20:37
towboat
阅读(14)
评论(0)
推荐(0)
摘要:
给一些串,问每个串的唯一前缀,若不存在输出本身 #include<iostream> #include <cstring> #include <algorithm> using namespace std ; const int N =1e5; int ch[N][30],tot,val[N]; v 阅读全文
posted @ 2023-02-26 19:55
towboat
阅读(11)
评论(0)
推荐(0)
摘要:
给一些字符串 , 问 是否有两个串有前缀关系 字典树节点维护结束标记 val[ ] , 跑的时候检查一下 #include<iostream> #include <algorithm> #include <cstring> using namespace std; const int N=1e5+4 阅读全文
posted @ 2023-02-26 17:36
towboat
阅读(172)
评论(0)
推荐(0)
摘要:
现在有个字典要支持一下操作 1、insert : 往神奇字典中插入一个单词 2、delete: 在神奇字典中删除所有前缀等于给定字符串的单词 3、search: 查询是否在神奇字典中有一个字符串的前缀等于给定的字符串 字典树每个节点维护 sum[ i ] delete 操作: 先查询包含该串的串个数 阅读全文
posted @ 2023-02-26 17:25
towboat
阅读(23)
评论(0)
推荐(0)
摘要:
给一些字符串,问以某个串为前缀的串有几个 #include<iostream> #include <algorithm> #include <cstring> using namespace std; const int N=5e5+4; char num[80]; int len,sum[N]; 阅读全文
posted @ 2023-02-26 17:02
towboat
阅读(18)
评论(0)
推荐(0)
摘要:
其中 f(1)=x0,f(2)=y0, f( i )=f( i-1 )+f( i+1 ),求 f(n) #include <iostream> #include <cmath> #include <algorithm> using namespace std; #define N 2 int mod 阅读全文
posted @ 2023-02-26 15:34
towboat
阅读(14)
评论(0)
推荐(0)
摘要:
ans=0; for(i=1;i<=n;i++) { if(i&1)ans=(ans*2+1)%m; else ans=ans*2%m; } 使用矩阵快速幂计算 f[n ] f[n] = f[n-1]+f[n-2]*2 +1 { f[n] ,f[n-1] ,1 } = { f[n-1] ,f[ n- 阅读全文
posted @ 2023-02-26 14:35
towboat
阅读(21)
评论(0)
推荐(0)
摘要:
#include <iostream> #include <cmath> #include <algorithm> using namespace std; #define N 2 int mod; #define int long long struct matrix { int a[N+2][N 阅读全文
posted @ 2023-02-26 12:32
towboat
阅读(6)
评论(0)
推荐(0)
摘要:
求矩阵的 k 次幂 #define int long long #define N 3 int mod =1e9+7; struct matrix { int a[N+2][N+2]; }; int n; void init_(matrix &x){ memset(x.a,0,sizeof x.a) 阅读全文
posted @ 2023-02-26 12:07
towboat
阅读(13)
评论(0)
推荐(0)
摘要:
定义某数组 xx 的权值为 sum{ sum{ a[i]+b[i] } } i<j<n 现在,给定两个长度为 nn 的数组 a,ba,b。你可以执行若干次操作,每次操作选择一个下标 ii,并交换 ai,bi 。 求在进行操作之后两个数组的权值之和最小能够达到多少。 = (a1+....an )^2 阅读全文
posted @ 2023-02-26 10:25
towboat
阅读(31)
评论(0)
推荐(0)